如题?

解决方案 »

  1.   

    procedure TForm1.Button2Click(Sender: TObject);
    var
      LVItem: TListItem;
      BDraw: Boolean;
    begin
      BDraw := True; //False
      ListView1CustomDrawItem(ListView1, LVItem, [cdsFocused], BDraw);
    end;
      

  2.   

    BDraw := True; //False
      LVItem := ListView1.Selected;   // 加一句
      

  3.   

    直接重画是不可以的哦!
    可以写一个用于重画的函数。unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ComCtrls, StdCtrls;type
      TForm1 = class(TForm)
        ListView1: TListView;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
        procedure CustomDrawItem(Sender: TCustomListView;
          Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.CustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
    begin
      if Item.Caption = 'Öйú' then
      begin
        (Sender as TListView).Canvas.Font.Color := clMaroon;
      end
      else if Item.Caption = 'Ó¢¹ú' then
      begin
        (Sender as TListView).Canvas.Font.Color := clRed;
      end
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
        State: TCustomDrawState; var DefaultDraw: Boolean;
    begin
        ListView1.OwnerDraw := true;
        CustomDrawItem(ListView1.Items.Owner, ListView1.Items.Item[0], State, DefaultDraw);
        CustomDrawItem(ListView1.Items.Owner, ListView1.Items.Item[1], State, DefaultDraw);
    end;end.
      

  4.   

    如果你直接使用ListView1CustomDrawItem
    那还能看到效果吗?
    所以,重画一般是单独的函数,就像菜单,工具条。
    一般为了所有的同类控件都能使用,都会写成函数的。
      

  5.   

    Rainsea(飞龙在天)说的对 可是怎么实现?