![]() |
#2
东海一鱼2010-08-02 11:00
|

procedure rowcolor(index:Integer);
var
rect:TRect;
begin
Rect.Left := 0 ;
Rect.Top := index * listbox1.ItemHeight ;
Rect.Bottom := Rect.Top + listbox1.ItemHeight ;
Rect.Right := listbox1.ClientWidth - 1;
listbox1.Canvas.FillRect(rect);
listbox1.Canvas.Font.Color:=clRed;
listbox1.Canvas.TextOut(rect.Left,rect.Top,listbox1.Items.Strings[index]);
end;
这是我写的一个过程,可以改变一行的颜色。但是当listbox被操作时,颜色会恢复到回原来的颜色。var
rect:TRect;
begin
Rect.Left := 0 ;
Rect.Top := index * listbox1.ItemHeight ;
Rect.Bottom := Rect.Top + listbox1.ItemHeight ;
Rect.Right := listbox1.ClientWidth - 1;
listbox1.Canvas.FillRect(rect);
listbox1.Canvas.Font.Color:=clRed;
listbox1.Canvas.TextOut(rect.Left,rect.Top,listbox1.Items.Strings[index]);
end;
想请教下有什么方法可以让颜色固定下来呢?