ListBox里的数据如何能通过鼠标的拖动改变顺序? 用鼠标拖拉就能改变ListBox里的数据的排列顺序,如何能实现呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var Index: Integer;procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);begin Index:=TListBox(Source).ItemIndex; ListBox1.OnEndDrag:=ListBox1EndDrag; if State<>dsDragMove then Accept:=false;end;procedure TForm1.ListBox1EndDrag(Sender, Target: TObject; X, Y: Integer);var Tmp: string;begin Tmp:=ListBox1.Items[ListBox1.ItemIndex]; ListBox1.Items[ListBox1.ItemIndex]:=ListBox1.Items[Index]; ListBox1.Items[Index]:=Tmp; ListBox1.OnEndDrag:=nil;end;end.你看这个效果怎么样?记得把DragMode属性设置成dmAutomatic哦。 DBGRIDEH表格功能非常强大,但不知如何用等于白费,求助! 请较这用什么打开,属于什么文件 求视频教程地址 怎样通过函数名称调用函数? intraweb开发一问,关于弹出菜单的 怎么快速添加多个控件 大家帮我看看这个观点是否正确 固定某列打印的问题? 控件透明区域的问题 如何监测鼠标在任何窗体上的左键单击? 问一个备份SQL SERVER 数据库(5G多)出错问题~~~~~~~~~~~~~~~~~在线等待 ACM延迟问题
Index: Integer;procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Index:=TListBox(Source).ItemIndex;
ListBox1.OnEndDrag:=ListBox1EndDrag;
if State<>dsDragMove then
Accept:=false;
end;procedure TForm1.ListBox1EndDrag(Sender, Target: TObject; X, Y: Integer);
var
Tmp: string;
begin
Tmp:=ListBox1.Items[ListBox1.ItemIndex];
ListBox1.Items[ListBox1.ItemIndex]:=ListBox1.Items[Index];
ListBox1.Items[Index]:=Tmp;
ListBox1.OnEndDrag:=nil;
end;end.你看这个效果怎么样?
记得把DragMode属性设置成dmAutomatic哦。