我想让listview中符合条件的列显示成红色  不知道那位可以帮忙解决一下

解决方案 »

  1.   

    例子,隔行设置不同颜色:
    procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
    begin
      if odd(item.Index)   then
        item.ListView.Canvas.Brush.Color := clBlue
      else
        item.ListView.Canvas.Brush.Color := clYellow;
    end;
      

  2.   

    如果我不想隔行  而是想设定条件  比如想让listview.items[i].subitems.strings[6]=''的列显示为红色  要如何了 请指教
      

  3.   

    还是在CustomDrawItem事件里判断:
    if item.subitems.strings[6]='' then // 符合条件
      item.ListView.Canvas.Brush.Color := clRed
    else
      item.ListView.Canvas.Brush.Color := clWhite;