vb6.0 怎样根据treeview中的节点,点击不同的节点使text显示不同的内容。例如点击机身,text内容显示机身
我的程序是这样的:PrivateSubtv1_NodeClick(ByValNodeAsMSComctlLib.Node)IfTreeView1.selectedItem...
我的程序是这样的:Private Sub tv1_NodeClick(ByVal Node As MSComctlLib.Node) If TreeView1.selectedItem.Children = 0 Then '检查是否有子节点,0为无 For i = 1 To TreeView1.Nodes.Count If TreeView1.Nodes(i).Selected Then MsgBox "您选择的是:“" & TreeView1.Nodes(i).FullPath & "”子节点!"
If TreeView1.selectedItem.Text = "机身" Then Text1.Text = "机身" ElseIf TreeView1.selectedItem.Text = "缸盖" Then Text1.Text = "缸盖" End If End If Next i End IfEnd Sub
Private Sub Form_Load()Dim MyNode As NodeSet MyNode = TreeView1.Nodes.Add(, , "gjj", "柴油机关键零部件")Set MyNode = TreeView1.Nodes.Add("gjj", tvwChild, "jishen", "机身")Set MyNode = TreeView1.Nodes.Add("gjj", tvwChild, "ganggai", "缸盖")Set MyNode = TreeView1.Nodes.Add("gjj", tvwChild, "quzhou", "曲轴")
TreeView1.Style = tvwTreelinesTextTreeView1.BorderStyle = ccFixedSingleEnd Sub 展开
If TreeView1.selectedItem.Text = "机身" Then Text1.Text = "机身" ElseIf TreeView1.selectedItem.Text = "缸盖" Then Text1.Text = "缸盖" End If End If Next i End IfEnd Sub
Private Sub Form_Load()Dim MyNode As NodeSet MyNode = TreeView1.Nodes.Add(, , "gjj", "柴油机关键零部件")Set MyNode = TreeView1.Nodes.Add("gjj", tvwChild, "jishen", "机身")Set MyNode = TreeView1.Nodes.Add("gjj", tvwChild, "ganggai", "缸盖")Set MyNode = TreeView1.Nodes.Add("gjj", tvwChild, "quzhou", "曲轴")
TreeView1.Style = tvwTreelinesTextTreeView1.BorderStyle = ccFixedSingleEnd Sub 展开
展开全部
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If TreeView1.SelectedItem.Children = 0 Then '检查是否有子节点,0为无
For i = 1 To TreeView1.Nodes.Count
If TreeView1.Nodes(i).Selected Then
Text1.Text = TreeView1.SelectedItem.Text
End If
Next i
End If
End Sub
If TreeView1.SelectedItem.Children = 0 Then '检查是否有子节点,0为无
For i = 1 To TreeView1.Nodes.Count
If TreeView1.Nodes(i).Selected Then
Text1.Text = TreeView1.SelectedItem.Text
End If
Next i
End If
End Sub
追问
原来是我把TreeView1缩写了,有些地方不一致。可以了 谢了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Text1.text = Node
End Sub
Text1.text = Node
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Text1.Text=ListView1.ListItems.Item(ListView1.SelectedItem.Index)
追问
我用的是treeview
追答
Text1.Text= TreeView1.SelectedItem
想要详细的下拉列表信息用TreeView1.SelectedItem.FullPath
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询