晓
晓鹤
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
procedure ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
procedure ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ListView1.BeginDrag(False,3);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i,j:integer;
Item:TListItem;
begin
for i := 0 to 9 do
begin
Item := ListView1.Items.Add;
Item.Caption := IntToStr(i);
for j := 1 to 3 do
begin
Item.SubItems.Add(IntToStr(i) + IntToStr(j));
end;
end;
end;
procedure TForm1.ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if (State = dsDragMove) and (Source = ListView1) then
Accept := True;
if State = dsDragLeave then
TControl(Sender).EndDrag(True);
end;
end.
每次拖动离开ListView时错误,为什么?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
procedure ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
procedure ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ListView1.BeginDrag(False,3);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i,j:integer;
Item:TListItem;
begin
for i := 0 to 9 do
begin
Item := ListView1.Items.Add;
Item.Caption := IntToStr(i);
for j := 1 to 3 do
begin
Item.SubItems.Add(IntToStr(i) + IntToStr(j));
end;
end;
end;
procedure TForm1.ListView1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if (State = dsDragMove) and (Source = ListView1) then
Accept := True;
if State = dsDragLeave then
TControl(Sender).EndDrag(True);
end;
end.
每次拖动离开ListView时错误,为什么?