最新国产好看的视频,伊人天堂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    //字體用原來默認(rèn)的顏色
 if Odd(index) then   //當(dāng)items的index為奇數(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ù)時的顏色
 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)選定時的顏色
 begin
  listbox1.Canvas.Brush.Color:=clhighlight;
  ListBox1.Canvas.TextRect(Rect,rect.Left,Rect.Top,ListBox1.Items[index]);
 end;
end;

相關(guān)文章

最新評論

德兴市| 灵宝市| 昔阳县| 申扎县| 大城县| 当阳市| 禹州市| 北宁市| 闻喜县| 平遥县| 张家口市| 永年县| 乌拉特后旗| 平邑县| 耒阳市| 万盛区| 荆州市| 抚顺县| 扎囊县| 上蔡县| 许昌县| 西吉县| 云南省| 湘乡市| 同仁县| 日照市| 衡水市| 樟树市| 宁波市| 房产| 天津市| 遵义县| 仙游县| 泗洪县| 普定县| 桑日县| 农安县| 垫江县| 福海县| 永清县| 庆安县|