listbox的拖动操作

字体大小: 中小 标准 ->行高大小: 标准
给你一个例子

比如窗体上有两个Listbox,下面将Listbox2中的项目拖到ListBox1中

将两个Listbox的DragMode属性设为dmAutomatic.

拖放经过事件

procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;

State: TDragState; var Accept: Boolean);

begin

if TListBox(Source)=ListBox2 then

Accept:=true;

end;

//拖放落下事件

procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: Integer);

begin

ListBox1.Items.Add(Listbox2.Items[ListBox2.ItemIndex]);

end;

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/68001.html