这里有ListView1和ListView2。
    我想在双击ListView1中的某条数据的时候,在ListView2中,将与Listview相同的数据显示为红颜色,怎么写?在什么事件里写?
    谢谢帮助!

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ComCtrls;type
      TForm1 = class(TForm)
        ListView1: TListView;
        ListView2: TListView;
        procedure ListView1CustomDrawItem(Sender: TCustomListView;
          Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
        procedure ListView1DblClick(Sender: TObject);
        procedure ListView1Exit(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        setColor:Boolean;
        function a(Str:String):Boolean;
      end;var
      Form1: TForm1;implementation{$R *.dfm}{ TForm1 }function TForm1.a(Str: String): Boolean;
    begin
      if setColor then begin
        if str = Listview1.Selected.Caption then
          result := True
        else result := False;
      end else result := False;
    end;procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
    begin
      if a(Item.Caption) then
        Listview2.Canvas.Brush.Color := clred
      else
        Listview2.Canvas.Brush.Color := clwindow
    end;procedure TForm1.ListView1DblClick(Sender: TObject);
    begin
      setColor := True;
      ListView2.Repaint;
    end;procedure TForm1.ListView1Exit(Sender: TObject);
    begin
      SetColor := False;
    end;end.
    {
    满不满意,哈哈,给分吧
    }
      

  2.   

    hety(笨菜阿诺德) 谢谢你的提示