【发布时间】:2012-02-28 21:44:56
【问题描述】:
我需要在我的Tlistbox 中拖放多个项目。
我指的代码是
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.
它工作正常,但我需要实现的是这样
.
为什么我想要这个是因为这些列表框项目有一定的顺序。 因此,我想启用多个拖放,而不是仅仅手动选择每个项目并拖放它。
感谢您对如何实现这一目标的任何看法。
如果以下可能使用相同的组件,也可以建议使用其他组件。
【问题讨论】:
标签: delphi drag-and-drop listbox delphi-xe