Accept := (Source <> Sender) and (Source Is TListBox)
if ((Source Is TFileListBox) and (Source <> Sender)) or ((Source Is TDirectoryListBox) and (Source <> Sender)) then Accept:=True; // accept drag operation我这样写 还是可以自身拖拽啊
1:将两个Listbox的DragMode属性设为dmAutomatic. 2:在Listbox1的onDragOver事件中写入: Delphi(Pascal) code procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin if Sender is TListBox then Accept:=true; end; 3:在Listbox1的onDragDrop事件中写入: Delphi(Pascal) code procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer); begin TListBox(sender).Items.Add(TListBox(Source).Items[TListBox(Source).itemindex]); TListBox(Source).Items.Delete(TListBox(Source).itemindex); end; 4:Listbox2的onDragOver事件指向Listbox1的onDragOver事件,onDragDrop事件指向Listbox1的onDragDrop的事件.
1:将两个Listbox的DragMode属性设为dmAutomatic. 2:在Listbox1的onDragOver事件中写入: procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin if Sender is TListBox then Accept:=true; end; 3:在Listbox1的onDragDrop事件中写入: procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer); begin TListBox(sender).Items.Add(TListBox(Source).Items[TListBox(Source).itemindex]); TListBox(Source).Items.Delete(TListBox(Source).itemindex); end; 4:Listbox2的onDragOver事件指向Listbox1的onDragOver事件,onDragDrop事件指向Listbox1的onDragDrop的事件.
if ((Source Is TFileListBox) and (Source <> Sender)) or ((Source Is TDirectoryListBox) and (Source <> Sender)) then
Accept:=True; // accept drag operation我这样写 还是可以自身拖拽啊
Delphi(Pascal) code
procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
if Sender is TListBox then
Accept:=true;
end;
3:在Listbox1的onDragDrop事件中写入:
Delphi(Pascal) code
procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
TListBox(sender).Items.Add(TListBox(Source).Items[TListBox(Source).itemindex]);
TListBox(Source).Items.Delete(TListBox(Source).itemindex);
end;
4:Listbox2的onDragOver事件指向Listbox1的onDragOver事件,onDragDrop事件指向Listbox1的onDragDrop的事件.
State: TDragState; var Accept: Boolean);
begin
if Sender is TListBox then
Accept:=true;
end; 3:在Listbox1的onDragDrop事件中写入: procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
TListBox(sender).Items.Add(TListBox(Source).Items[TListBox(Source).itemindex]);
TListBox(Source).Items.Delete(TListBox(Source).itemindex);
end;
4:Listbox2的onDragOver事件指向Listbox1的onDragOver事件,onDragDrop事件指向Listbox1的onDragDrop的事件.
我拖拽已经实现了
只是要禁止自身拖拽而已