设置BCB中ListView中的Item控件颜色


//根据Item的索引值,对ListView的AdvancedCustomDrawItem事件进行处理.

void __fastcall TForm1::ListView1AdvancedCustomDrawItem(
       TCustomListView *Sender, TListItem *Item, TCustomDrawState State,
       TCustomDrawStage Stage, bool &DefaultDraw)
{
     // if( ListView1->Selected )
     if( Item->StateIndex == 2 )
     {
         Sender->Canvas->Font->Color    =    clBlack;
         Sender->Canvas->Brush->Color    =    clRed;
     }
      if( Item->StateIndex == 1 )
     {
         Sender->Canvas->Font->Color    =    clBlack;
         Sender->Canvas->Brush->Color    =    clGreen;
     }
      if( Item->StateIndex == 3 )
     {
         Sender->Canvas->Font->Color    =    clBlack;
         Sender->Canvas->Brush->Color    =   (TColor)(0x000080);
     }

}