Autor Beitrag
bernd29
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 116

winxp
D7 und VB6
BeitragVerfasst: Fr 04.08.06 15:56 
hallo,

ich will in meiner listbox zwei select balken haben .

einen bekomme ich ja schon hin mit drawitem, kuckst du.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
    if odselected in state then begin
      if (ListBox1.Selected[index]) or (odselected in state) then
        canvas.brush.color:= clNavy ;
    end;



hat jemand ne idee ????

gruss bernd

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt
Moderiert von user profile iconChristian S.: Topic aus Multimedia / Grafik verschoben am Fr 04.08.2006 um 19:52

_________________
Es ist keine Schande, nichts zu wissen, wohl aber, nichts lernen zu wollen.
Sokrates
Arno Nym
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 131



BeitragVerfasst: Fr 04.08.06 18:16 
Hi!
ich verstehe das Problem nicht ganz. Mit der Listbox-Eigenschaft "multiselect" auf true, kannst du doch mehrere Items in der Listbox auswählen. Warum willst du da was neu zeichnen, da sind doch dann alle selektierten Items markiert ?
MFG, Arno Nym
bernd29 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 116

winxp
D7 und VB6
BeitragVerfasst: Sa 05.08.06 09:31 
Hallo,

Danke für die Antwort.

Das Problem :

Ich habe ne Listbox und 2 Button auf meiner Form .
Wenn ich auf Button1 clicke, soll der erste eintrag Blau makiert sein (das geht ja).
Wenn nich nun auf Button2 clicke, soll ein neuer Balken dazu kommen in rot .

Und das bekomme ich net hin :cry:


Gruss Bernd

_________________
Es ist keine Schande, nichts zu wissen, wohl aber, nichts lernen zu wollen.
Sokrates
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 05.08.06 09:55 
Dann Schau mal nach OnDrawItem.
bernd29 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 116

winxp
D7 und VB6
BeitragVerfasst: Sa 05.08.06 10:24 
Hallo,

Hab ich doch ,aber er zeichnet mir nur ein Balken.


MfG

_________________
Es ist keine Schande, nichts zu wissen, wohl aber, nichts lernen zu wollen.
Sokrates
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 05.08.06 13:50 
Geht bestimmt noch Einfacher aber Ich hoffe das hilft Dir ein wenig.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
var
  Form1: TForm1;
  i:Integer;
implementation

{$R *.dfm}

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
begin
  i:=Listbox1.ItemIndex;
  with TListBox(Control), Canvas do
  begin
    if i=0 then
    Brush.Color:=clBlue ;
    if i=1 then
    Brush.Color:=clRed ;
    Canvas.FillRect(Rect);
    TextOut(Rect.left,Rect.top,Items[index]);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  i:=0;
  Listbox1.Selected[i]:=True;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  i:=1;
  Listbox1.Selected[i]:=True;
end;

end.