请教如何改变ListBox当前记录颜色的问题!(在线等待) 想把 ItemIndex 记录默认的深蓝色换成别的颜色,如何实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个试试看,拷过来的把Listbox的style属性改为lbOwnerDrawVariable以后,要怎么显示你就可以随心所欲了。只在两个事件中写代码即可:procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer; var Height: Integer);begin Height := Index Mod 3 * 2 + ListBox1.ItemHeight; //你要画的每个Item的高度,根据字体不同而不同,我这是随便取了几个不同的值end;procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);begin ListBox1.Canvas.Brush.Color := Index * $A0F0F0; ListBox1.Canvas.FillRect(Rect);//上面的代码是填充Item的背景,下面画出每个Item的文字,可以为每个Item设置不同的字体及着色 if Index mod 2 = 0 then begin ListBox1.Canvas.Font.Name := 'Impact'; ListBox1.Canvas.Font.Color := clLime; end else begin ListBox1.Canvas.Font.Name := 'Tahoma'; ListBox1.Canvas.Font.Color := clRed; end;//用Canvas的TextOut画出文字: ListBox1.Canvas.TextOut(Rect.Left, Rect.Top, ListBox1.Items[Index]);end; 请问怎么用ADOTable+filter进行模糊查询? 在Form里如何捕捉动态生成Frame的鼠标单击事件 请教关于指针数组 GLSence载入纹理问题 为什么这几行代码不对。 delphi控制word表格的上标,如何实现 使用vclzip的問題 四个简单的小问题 我用ADO连接一个Access数据库 如何改变菜单中的字体大小以及如何toolbar中图标大小会按钮大小变化 关于窗体继承? 谁能告诉我????------有关视图及其引用基表的操作
把Listbox的style属性改为lbOwnerDrawVariable以后,要怎么显示你就可以随心所欲了。
只在两个事件中写代码即可:procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
begin
Height := Index Mod 3 * 2 + ListBox1.ItemHeight;
//你要画的每个Item的高度,根据字体不同而不同,我这是随便取了几个不同的值
end;procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
begin
ListBox1.Canvas.Brush.Color := Index * $A0F0F0;
ListBox1.Canvas.FillRect(Rect);
//上面的代码是填充Item的背景,下面画出每个Item的文字,可以为每个Item设置不同的字体及着色
if Index mod 2 = 0 then
begin
ListBox1.Canvas.Font.Name := 'Impact';
ListBox1.Canvas.Font.Color := clLime;
end
else
begin
ListBox1.Canvas.Font.Name := 'Tahoma';
ListBox1.Canvas.Font.Color := clRed;
end;
//用Canvas的TextOut画出文字:
ListBox1.Canvas.TextOut(Rect.Left, Rect.Top, ListBox1.Items[Index]);
end;