最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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

ListBox1 的 Style 屬性改為 lbOwnerDrawVariable

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

示例代碼如下:

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

相關(guān)文章

最新評論

丰台区| 疏附县| 仙游县| 清镇市| 石阡县| 榆中县| 河津市| 夏邑县| 桦甸市| 平潭县| 会理县| 攀枝花市| 固始县| 青海省| 武夷山市| 水城县| 昌吉市| 长子县| 酉阳| 晋中市| 图们市| 如皋市| 淳安县| 潜山县| 盖州市| 岢岚县| 禄丰县| 义马市| 临江市| 苗栗县| 平阴县| 讷河市| 平定县| 赤水市| 开鲁县| 噶尔县| 进贤县| 辽宁省| 涟水县| 贞丰县| 峨眉山市|