1 在构造函数中
ListView1->OwnerDraw = true;
ListView1->StateImages= ImageList1;
ListView1->OnDrawItem =(TLVDrawItemEvent)&CrnDrawListViewItem;
2 响应函数
void __fastcall TfmMipian:: CrnDrawListViewItem(TCustomListView *Sender,TListItem *Item, TRect &Rect, TOwnerDrawState State)
{
TListView *lv = (TListView *)Sender;
// Rect
TRect rct(Rect.Left + 1, Rect.Top, Rect.Width() - 1, Rect.Bottom);
// Fill background
if(State.Contains(odFocused) || State.Contains(odSelected))
{
// With focus
lv->Canvas->Brush->Color = MYCOLOR_BACK;
lv->Canvas->FillRect(rct);
lv->Canvas->Pen->Color = MYCOLOR_BORDER;
lv->Canvas->Rectangle(rct);
}
else
{
lv->Canvas->Brush->Color = lv->Color;
lv->Canvas->FillRect(Rect);
}
int nLeftOffset(0);
if(lv->Checkboxes)
{
lv->Canv