xianjun说的对,我不是用的VCL的Tlistview,但VCL的TListView的parent属性同样是TWidgetControl类型的
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Buttons, StdCtrls, ComCtrls, ImgList, DB, ADODB, NMUDP,
Psock, NMMSG, QComCtrls;//------注意这里
type
TMyLtVw=class(TListView)
procedure OnItemDbClk(Sender: TObject; Item: TListItem);
public
constructor Create(AOwner: TComponent);override;
end;
procedure TMyLtVw.OnItemDbClk(Sender: TObject; Item: TListItem);
begin
ShowMessage(Item.Caption);
end;
constructor TMyLtVw.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
OnItemDoubleClick:=OnItemDbClk;
end;
procedure TMainFm.FormCreate(Sender: TObject);
begin
UserLtVw:=TMyLtVw.Create(self);
try
with UserLtVw do begin
Left:=0;Top:=0;
Width:=100;Height:=200;
Parent:=Self;
Visible:=true;
end;
except
ShowMessage('Error');
end;
end;