亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Delphi實(shí)現(xiàn)Listbox中的item根據(jù)內(nèi)容顯示不同顏色的方法

 更新時(shí)間:2014年07月17日 10:30:42   投稿:shichen2014  
這篇文章主要介紹了Delphi實(shí)現(xiàn)Listbox中的item根據(jù)內(nèi)容顯示不同顏色的方法,需要的朋友可以參考下

本文簡(jiǎn)述了Delphi實(shí)現(xiàn)Listbox中的item根據(jù)內(nèi)容顯示不同顏色的方法,實(shí)現(xiàn)步驟如下:

ListBox1 的 Style 屬性改為 lbOwnerDrawVariable

在ListBox的OnDrawItem事件裡,根據(jù)item的值,改變Canvas屬性

示例代碼如下:

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin    //字體用原來(lái)默認(rèn)的顏色
 if Odd(index) then   //當(dāng)items的index為奇數(shù)時(shí)的顏色
 begin
  listbox1.Canvas.Brush.Color:=clwindow;
  ListBox1.Canvas.TextRect(Rect,rect.Left,Rect.Top,ListBox1.Items[index]);
 end
 else     //當(dāng)items的index為偶數(shù)時(shí)的顏色
 begin
  listbox1.Canvas.Brush.Color:=clinactivecaptiontext;
  ListBox1.Canvas.TextRect(Rect,rect.Left,Rect.Top,ListBox1.Items[index]);
 end;
 if  odSelected  in  state  then    //當(dāng)選定時(shí)的顏色
 begin
  listbox1.Canvas.Brush.Color:=clhighlight;
  ListBox1.Canvas.TextRect(Rect,rect.Left,Rect.Top,ListBox1.Items[index]);
 end;
end;

相關(guān)文章

最新評(píng)論