taposh_dr
asked on
Treeview setfocus or setselected
Hello,
I am using the treeview mousedown event to get another form. After the new form has been loaded, I would like the
focus from the selected item to move down to the child node, I am unable to do it as setfocus is a read only function.
I need to know how to solve it. Any Ideas???
T
I am using the treeview mousedown event to get another form. After the new form has been loaded, I would like the
focus from the selected item to move down to the child node, I am unable to do it as setfocus is a read only function.
I need to know how to solve it. Any Ideas???
T
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I forgot, before the if you can insert your form load code :-)
You will need to code de beforeSelect event of the tree view using the FirstNode property.
Something like this:
Private Sub TreeView2_BeforeSelect(ByV
'First we verify the existence of a chilnode
If Not e.Node.FirstNode Is Nothing Then
'If it exists the we asign it to the selectednode property of the sender
CType(sender, TreeView).SelectedNode = e.Node.FirstNode
'and then we cancel the original operation, without this it will focus
'the original node
e.Cancel = True
End If
End Sub