3
我需要拖放我的Tlistbox
内的多个项目。
我这里指的是代码是德尔福listbox拖放多个项目
var
StartingPoint : TPoint;
implementation
...
procedure TForm1.FormCreate(Sender: TObject) ;
begin
ListBox1.DragMode := dmAutomatic;
end;
procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer) ;
var
DropPosition, StartPosition: Integer;
DropPoint: TPoint;
begin
DropPoint.X := X;
DropPoint.Y := Y;
with Source as TListBox do
begin
StartPosition := ItemAtPos(StartingPoint,True) ;
DropPosition := ItemAtPos(DropPoint,True) ;
Items.Move(StartPosition, DropPosition) ;
end;
end;
procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean) ;
begin
Accept := Source = ListBox1;
end;
procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer) ;
begin
StartingPoint.X := X;
StartingPoint.Y := Y;
end;
from here。
它工作正常,但我需要实现的是这样的 。
为什么我想这是因为有一定的顺序对应于这些列表框项目。 因此,不是只需手动选择每个项目并拖放它,我想要启用多个拖放。
任何意见,我该如何实现这一点表示赞赏。
也可以建议使用其他组件,如果以下可能使用相同的。
您正在使用以前版本的代码。错误现在已修复。就像我说的,要想得到正确的令人惊讶的棘手问题! – 2012-02-07 13:39:07
非常感谢! :) – Shirish11 2012-02-09 07:50:47