![]() |
|
|
#1
|
||||
|
||||
|
пытаюсь раскрасить ListBox:
Код:
procedure TForm1.ListBox2DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
if odSelected in State then
begin
ListBox2.Canvas.Brush.Color:=clLime;
ListBox2.Canvas.Font.Color:=clBlack;
end;
if Index=N then
begin
ListBox2.Canvas.Brush.Color:=clBlue;
ListBox2.Canvas.Font.Color:=clWhite;
end;
ListBox2.Canvas.FillRect(Rect);
ListBox2.Canvas.TextOut(Rect.Left+2,Rect.Top,ListBox2.Items[Index]);
end;![]() |
|
#2
|
|||
|
|||
|
А так:
Код:
procedure TForm1.ListBox2DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
if odSelected in State then
begin
ListBox2.Canvas.Brush.Color:=clLime;
ListBox2.Canvas.Font.Color:=clBlack;
end
Else
if Index=N then
begin
ListBox2.Canvas.Brush.Color:=clBlue;
ListBox2.Canvas.Font.Color:=clWhite;
end;
ListBox2.Canvas.FillRect(Rect);
ListBox2.Canvas.TextOut(Rect.Left+2,Rect.Top,ListBox2.Items[Index]);
end; |
|
#3
|
||||
|
||||
|
надо было добавить в процедуру, в которой изменяется индекс:
Код:
ListBox2.Repaint; Последний раз редактировалось ryderx34, 28.03.2010 в 01:16. |