例如说有10条数据要显示在listbox中
我想让其中的几条数据的字体颜色变成红色
该如何做
我试了一下字体颜色都变成红色了:(
在DrawItem事件裡面處理
大哥,我急等分用哟
1.ListBox的Style设置为lbOwnerDrawFixed
2.代码如下:假如1,2,3,6是错误数据,你可以根据自己的需要进行修改
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var ss:string;
begin
ss:=ListBox1.Items[Index];
ListBox1.Canvas.TextRect(Rect,Rect.Left+1,Rect.+1,ss);
if (ss=1)or(ss=2)or(ss=3)or(ss=6) then
with ListBox1.Canvas do begin
FillRect(Rect);
Font.Color:=clRed;
TextOut(Rect.Left,Rect.,ss);
end;
end;