TREEVIEW的问题
如果想在单击某个按钮后TREEVIEW里面的第一项被选中,这样要怎么实现才好呢,我做了好久都做不出来.请帮一下忙
至于你提到的问题,可能是因为treeview控件本身的功能局限,而不能通过button这样控件的click事件,来把选择焦点传给treeview1指定的项.
本例提供另外一种方式,可以实现类似的功能:
Dim s As Boolean
Private Sub forever_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TreeView1.CheckBoxes = True
End Sub
Private Sub wishes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles wishes.Click
If s = True Then
Me.TreeView1.GetNodeAt(0, 0).Checked = False
'或Me.TreeView1.Nodes.Item(0).Checked = False
s = False
Else
Me.TreeView1.GetNodeAt(0, 0).Checked = True
'或Me.TreeView1.Nodes.Item(0).Checked = True
s = True
End If
End Sub