ListBox中不算难的问题(字体显示方面) ListBox中增加两个文件,能不能让第一个文件显示的字体为红色,粗体,而第二个文件显示黑色,正常体? 解决方案 » 免费领取超大流量手机卡,每月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; 时间查询急呀!~~ 请问,用ASP做好的程序,能否转为软件?? 求三层设计模式的例子 小弟是新手,做了一个登陆界面,有些错误,请各位高手找找错误!! 能否连续赋值?很菜的问题!!!请指教 在什么样的情况下考虑使用多层结构,什么样的情况下使用两层结构? 在DELPHI中如何不根据后缀名称来分别文件格式。(图片) 怎么样解决控件重画时的闪烁问题 adoquery的事务处理代码如何写?请给代码!连接MSSQL!有连接ADOCONNECTION oracle的存储过程如何返回结果集 spcomm在98系统下怎么读取的数据不完整? 谁熟悉DLL的,请进
只在两个事件中写代码即可: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;