请教!!关于treeview和listview之间拖动问题?

cool_sky 2003-12-17 09:55:53
我想把listview中的选项拖到treeview某个节点下,同时将数据库中的数据也添加,应该如何实现?
请各位指点一下,谢谢
...全文
34 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
cool_sky 2003-12-23
  • 打赏
  • 举报
回复
没有人帮忙吗??:(
自己顶一下
cool_sky 2003-12-23
  • 打赏
  • 举报
回复
谢谢lihonggen0
基本功能实现,还想请教一个问题,就是拖动时整个listview一起拖动,可不可以不显示整个listview框,只显示拖动项?
arvid_gs 2003-12-23
  • 打赏
  • 举报
回复
这里面的换一下就可以:
Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
ListView1.DragIcon = ListView1.SelectedItem.CreateDragImage
ListView1.Drag vbBeginDrag
End If
End Sub
lihonggen0 2003-12-18
  • 打赏
  • 举报
回复
Option Explicit
Private Sub Form_Load()
TreeView1.Nodes.Add , , "aa", "aa"
TreeView1.Nodes.Add , , "bb", "bb"
ListView1.ListItems.Add , , "cc"
ListView1.ListItems.Add , , "dd"
ListView1.OLEDragMode = ccOLEDragAutomatic
ListView1.LabelEdit = lvwManual
End Sub

Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
ListView1.DragIcon = ListView1.SelectedItem.CreateDragImage
ListView1.Drag vbBeginDrag
End If
End Sub

Private Sub TreeView1_DragDrop(Source As Control, x As Single, y As Single)
If Not TreeView1.DropHighlight Is Nothing Then
TreeView1.Nodes.Add TreeView1.DropHighlight.Key, tvwChild, GetNextKey() & ListView1.SelectedItem.Text, ListView1.SelectedItem.Text
TreeView1.DropHighlight.Expanded = True
End If
End Sub
Private Sub TreeView1_DragOver(Source As Control, x As Single, y As Single, State As Integer)
Set TreeView1.DropHighlight = TreeView1.HitTest(x, y)
End Sub

Private Function GetNextKey() As String
On Error GoTo MyErr
Dim sNewKey As String
Dim iHold As Integer
Dim i As Integer
On Error GoTo MyErr
iHold = Val(TreeView1.Nodes(1).Key)
For i = 1 To TreeView1.Nodes.Count
If Val(TreeView1.Nodes(i).Key) > iHold Then
iHold = Val(TreeView1.Nodes(i).Key)
End If
Next
iHold = iHold + 1
sNewKey = CStr(iHold) & "_"
GetNextKey = sNewKey
Exit Function
MyErr:
GetNextKey = "1_"
End Function

cool_sky 2003-12-18
  • 打赏
  • 举报
回复
呵呵,我的意思就是怎么实现这个功能?
设想是在listview的mousedown选中某项,在treeview的dragdrop添加这项
将listview的dragmode设为自动,但拖动时无法看到选中某项,我想实现,在listview中,鼠标选中,则高亮显示,拖动这项,而不是整个listview拖动
请各位提提意见
VCSQLVB 2003-12-17
  • 打赏
  • 举报
回复
选择listview时,将要添加的内容,新增到treeview,再把其他的加到数据库就行了。

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧