在XE2下我遇到的问题是,当选择一行并且鼠标移动到另一行时,标准TListLiew会留下选择标记。可以使用以下代码轻松复制:
unit MainForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
lvw: TListView;
procedure lvwData(Sender: TObject; Item: TListItem);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
col: TListColumn;
begin
lvw := TListView.Create(Self);
lvw.Parent := self;
lvw.Align := alClient;
lvw.MultiSelect := true;
lvw.RowSelect := true;
lvw.ViewStyle := vsReport;
lvw.OwnerData := true;
col := lvw.Columns.Add;
col.Caption := 'First';
col.Width := 100;
col := lvw.Columns.Add;
col.Caption := 'Second';
col.Width := 100;
lvw.OnData := lvwData;
lvw.Items.Count := 15
end;
procedure TForm1.lvwData(Sender: TObject; Item: TListItem);
begin
Item.Caption := 'Hallo';
Item.SubItems.Add('Halli');
end;
end.
当我选择一行或多行并将鼠标移到另一行时,会产生以下结果:
&#34>"掉线"当鼠标移过先前选定的行时,将清除选择标记。