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

cool_sky 2003-12-17 09:55:53
我想把listview中的选项拖到treeview某个节点下,同时将数据库中的数据也添加,应该如何实现?
请各位指点一下,谢谢
...全文
8 点赞 收藏 6
写回复
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,再把其他的加到数据库就行了。
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7453

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告