unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls,commctrl;
//要添加commctrl单元
type
TForm1 = class(TForm)
Button1: TButton;
ListView1: TListView;
procedure ListView1DblClick(Sender: TObject);
procedure ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
thex,they:integer;
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.ListView1DblClick(Sender: TObject);
var ls:LV_HITTESTINFO;
begin
ls.pt.x:=thex;
ls.pt.y:=they;
ListView_SubItemHitTest(listview1.Handle,@ls);
//showmessage(inttostr(ls.pt.x));
showmessage('你双击的是第'+inttostr(ls.iSubItem)+'列');
end;procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
thex:=x;
they:=y;
end;end.
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls,commctrl;
//要添加commctrl单元
type
TForm1 = class(TForm)
Button1: TButton;
ListView1: TListView;
procedure ListView1DblClick(Sender: TObject);
procedure ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;var
thex,they:integer;
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.ListView1DblClick(Sender: TObject);
var ls:LV_HITTESTINFO;
begin
ls.pt.x:=thex;
ls.pt.y:=they;
ListView_SubItemHitTest(listview1.Handle,@ls);
//showmessage(inttostr(ls.pt.x));
showmessage('你双击的是第'+inttostr(ls.iSubItem)+'列');
end;procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
thex:=x;
they:=y;
end;end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货