一个ListView,已加载10多个图标,现在需要随时用鼠标改变某个图标的位置,比如:用鼠标把第2个图标拖到第4个图标右侧并放下(这一功能已实现),问题是:怎样在鼠标释放按键时,判断当前插入的位置是第几个图标呢?拖动的代码如下:ListView 的DragMode已设成自动
procedure TForm1.ListView1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := Source is TListView
end;procedure TForm1.ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
PosPoint: TPoint;
begin
PosPoint.x := x;
PosPoint.y := Y;
(Source as TListView).Selected.SetPosition(PosPoint);
end;以上代码可以实现拖动,但并不能实现图标拖动后判断插入的位置希望各位大侠能有好办法,谢谢
procedure TForm1.ListView1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := Source is TListView
end;procedure TForm1.ListView1DragDrop(Sender, Source: TObject; X, Y: Integer);
var
PosPoint: TPoint;
begin
PosPoint.x := x;
PosPoint.y := Y;
(Source as TListView).Selected.SetPosition(PosPoint);
end;以上代码可以实现拖动,但并不能实现图标拖动后判断插入的位置希望各位大侠能有好办法,谢谢
解决方案 »
- delphi:operation cannot mix aggregate value with record-varying value 错误提示什么意思
- RichEdit中的文本text怎么存成txt文件,以便用计事本打开?,使用TStrings 的savetofile有点问题。
- 问一个SQL语句的问题
- fastreport怎样竖直显示,且中间有一个空隔
- listview的listitem有没有类似由vb中的tag属性?问题解决,马上给分
- 那有网页编辑组件?
- sql2000中不用自动增量,是否可以用其它的数字来代替它,如时间等,请大家给哥参考
- 求解!只打印出了四分之一版面?
- 如何在DBGrid中用(移到下一条或上一条)移动一页
- delphi中如何实现单元格的自动填充呀
- 100分求人,我先做了70多个窗体.高手快来!
- Delphi 中怎样根据 字符串 创建 并 调用对象?
var
PosPoint: TPoint;
Item:TListItem;
begin
PosPoint.x := x;
PosPoint.y := Y;
Item := ListView1.GetItemAt(x,y);
Item.Index就是目标图标的位置
(Source as TListView).Selected.SetPosition(PosPoint);
end;
PosPoint: TPoint;
Item:TListItem;
begin
PosPoint.x := x;
PosPoint.y := Y;
Item := ListView1.GetItemAt(x,y);
Item.Index就是目标图标的位置
(Source as TListView).Selected.SetPosition(PosPoint);
end;按以上代码测试,会出现致命错误,估计是Item.Index的问题,尚不知原因,继续测试中
谢谢大家,大家辛苦了。散分散贴了