以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 请教:ListView控件分组显示数据时,如何从一组中拖动一行到另一组? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=193491) |
-- 作者:y2287958 -- 发布时间:2024/9/19 16:39:00 -- 请教:ListView控件分组显示数据时,如何从一组中拖动一行到另一组? 如题,例如:http://www.foxtable.com/webhelp/index.htm?page=2772.htm中如何将“欧洲国家”组中的“法国”拖动到“亚洲国家”组中 |
-- 作者:有点蓝 -- 发布时间:2024/9/19 23:28:00 -- 有点不是很完美 窗口afterload事件 Dim lvw As WinForm.ListView = e.Form.Controls("ListView1") Dim listView1 As System.Windows.Forms.ListView = lvw.BaseControl AddHandler listView1.DragDrop, AddressOf ListView1_DragDrop 全局代码 Public Sub listView1_DragDrop( sender As Object, e As System.Windows.Forms.DragEventArgs) Dim listView1 As System.Windows.Forms.ListView = sender Dim draggedItem As System.Windows.Forms.ListViewItem = e.Data.GetData(GetType(System.Windows.Forms.ListViewItem)) \'Output.Show("draggedItem.text=" & draggedItem.Text) Dim point As Point = listView1.PointToClient(New Point(e.X, e.Y)) Dim targetItem As System.Windows.Forms.ListViewItem = listView1.GetItemAt(point.X, point.Y) If targetItem IsNot Nothing Then Dim newGroup As System.Windows.Forms.ListViewGroup = targetItem.Group \' Output.Show("newGroup=" & (newGroup Is Nothing)) If newGroup IsNot Nothing Then Output.Show("newGroup=" & newGroup.Name) draggedItem.Group = newGroup Output.Show("targetItem.Index=" & targetItem.Index) End If End If End Sub |
-- 作者:y2287958 -- 发布时间:2024/9/20 8:07:00 -- 虽然效果未达到,但还是谢谢版主 |