1 void "#0000FF">__fastcall TForm1::ListBox1DrawItem(TWinControl *Control, int Index,
2 TRect &Rect, TOwnerDrawState State)
3 {
4 if(State.Contains(odSelected))
5 {
6 ListBox1->Canvas->Brush->Color = clBlue;
7 ListBox1->Canvas->Font->Color = clYellow;
8 }
9 else
10 {
11 ListBox1->Canvas->Brush->Color = clWhite;
12 ListBox1->Canvas->Font->Color = clBlack;
13 }
14 ListBox1->Canvas->FillRect(Rect);
15 ListBox1->Canvas->TextOut(Rect.Left, Rect.Top, ListBox1->Items->Strings[Index]);
16 }





記得要先把 ListBox1 的 Style 屬性改成 lbOwnerDrawVariable
或是 lbOwnerDrawFixed

全站熱搜

Nelson 發表在 痞客邦 留言(0) 人氣()