帮助中说,要将OwnerDraw属性设置成False时,上述两事件才会触发.
可是,我并没有发现这两个事件能够绘画"SubItems"里的东西,包括字体,
背景,色彩等, 既然不能修改SubItem,为什么还要叫"...DrawSubItem()"呢?
请问大家,有谁知道怎么做才能绘画SubItem内容,包括字体/色彩等??
最好附上代码说明, 因为语言还是太难描述了.

解决方案 »

  1.   

    //OwnerDraw不用设置为False就可以触发了~~
    procedure TForm1.ListView1AdvancedCustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
      var DefaultDraw: Boolean);
    begin
      if Odd(Item.Index) then begin
        Sender.Canvas.Font.Color := clRed;
        Sender.Canvas.Brush.Color := clBlue;
      end;
    end;procedure TForm1.ListView1AdvancedCustomDrawSubItem(
      Sender: TCustomListView; Item: TListItem; SubItem: Integer;
      State: TCustomDrawState; Stage: TCustomDrawStage;
      var DefaultDraw: Boolean);
    begin
      if Odd(Item.Index) then begin
        Sender.Canvas.Font.Color := clRed;
        Sender.Canvas.Brush.Color := clBlue;
      end;
      if Odd(SubItem) then
        Sender.Canvas.Font.Style := [fsBold];
    end;
      

  2.   

    字体色彩呢? 你只修改了字体的方式, 尤其是SubItem, 好像不能修改似的!
      

  3.   

    怎么单独修改某一个Cell里的颜色呢?
      

  4.   

    谢谢  zswangII(伴水清清)(职业清洁工)  的启发, 如下是我已经实现的代码: :P    with Sender.Canvas do
        begin
          case Pred (SubItem) of
          0:
            begin
              if 0 = CompareText ('11', Item.SubItems.Strings[Pred (SubItem)]) then
              begin
                Font.Color := clRed;
                Font.Style := [fsBold];
              end
              else if 0 = CompareText ('21', Item.SubItems.Strings[Pred (SubItem)]) then
              begin
                Font.Color := clLime;
                Font.Style := [fsBold];
              end
              else if 0 = CompareText ('31', Item.SubItems.Strings[Pred (SubItem)]) then
              begin
                Font.Color := clHotLight;
                Font.Style := [fsBold];
              end;
            end;
          1:
            begin
              if 0 = CompareText ('12', Item.SubItems.Strings[Pred (SubItem)]) then
              begin
                Font.Color := clLime;
                Font.Style := [fsBold];
              end else
              if 0 = CompareText ('22', Item.SubItems.Strings[Pred (SubItem)]) then
              begin
                Font.Color := clRed;
                Font.Style := [fsBold];
              end else
              if 0 = CompareText ('32', Item.SubItems.Strings[Pred (SubItem)]) then
              begin
                Font.Color := clSkyBlue;
                Font.Style := [fsBold];
              end;
            end;
          2:
            begin
              if 0 = CompareText ('13', Item.SubItems.Strings[Pred (SubItem)]) then
              begin
                Font.Color := clYellow;
                Font.Style := [fsBold];
              end;
              if 0 = CompareText ('23', Item.SubItems.Strings[Pred (SubItem)]) then
              begin
                Font.Color := clLime;
                Font.Style := [fsBold];
              end;
              if 0 = CompareText ('33', Item.SubItems.Strings[Pred (SubItem)]) then
              begin
                Font.Color := clFuchsia;
                Font.Style := [fsBold];
              end;
            end;
          else
            Font.Color := clHighLight;
          end;
        end;
    搞定!