treeview collapse problem

S

Shawn

Hi.

I'm having a problem with the TreeView control. If a node is selected and I
click to collapse it's parent node then the parent node becomes selected and
the SelectedNodeChanged event fires. This makes me unable to tell whether a
node has been selected or just collapsed. I need to be able to check in the
method that handles the SelectedNodeChanged event whether the node has been
clicked on by the user or just collapsed.

Any ideas?

Thanks,
Shawn
 
S

Shawn

I came up with a solution. Though I might post it if anyone else has the
same problem.

Dim node As TreeNode
Dim arrayIndex As Array

'Check if the newly selected node is a parent of the previously selected
node.
If e.OldNode.StartsWith(e.NewNode) Then
arrayIndex = e.NewNode.Split("."c)

'Get the newly selected node.
If arrayIndex.Length = 1 Then
node = TreeView.Nodes(arrayIndex(0))
ElseIf arrayIndex.Length = 2 Then
node = TreeView.Nodes(arrayIndex(0)).Nodes(arrayIndex(1))
ElseIf arrayIndex.Length = 3 Then
node =
TreeView.Nodes(arrayIndex(0)).Nodes(arrayIndex(1)).Nodes(arrayIndex(2))
End If

'Only bind data to the DataGrid if this isn't a cause of collapsing the
TreeView.
If node.Expanded = True Then
BindData(e.NewNode)
End If
Else
BindData(e.NewNode)
End If


Hi.

I'm having a problem with the TreeView control. If a node is selected and I
click to collapse it's parent node then the parent node becomes selected and
the SelectedNodeChanged event fires. This makes me unable to tell whether a
node has been selected or just collapsed. I need to be able to check in the
method that handles the SelectedNodeChanged event whether the node has been
clicked on by the user or just collapsed.

Any ideas?

Thanks,
Shawn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top