TreeView SelectedNode issues

0
0
  1. On load, WinForms TreeView automatically selects the first TreeView node. On load, Wisej TreeView doesn’t select any node (SelectedNode is set to null). That’s not very important, it’s more a question of personal preference.
  2. When I set SelectedNode = null, in WinForms no Select events (OnBeforeSelect/OnAfterSelect ) are raised. InWisej OnBeforeSelect and OnAfterSelect are raised with e.Node = null. Furthermore, when base.OnBeforeSelect(e) and base.OnAfterSelect(e) is executed, Wisej code throws a null reference exception.

As usual, a WinForms/Wisej sample is attached.

  • You must to post comments
0
0

If I understand it correctly, the events will be fired but base.OnBeforeSelect(e) and base.OnAfterSelect(e) won’t raise a NullReferenceException.

Please confirm so I fix the code accordingly.

  • Luca (ITG)
    Yes, e.Node is null but you can set e.Cancel = true on OnBeforeSelect to prevent the TreeView selection from being cleared. Also in OnAfterSelect e.Node is null which lets you determine that the selection was cleared. Similar to SelectedIndex = -1. Also our TreeView supports multiple selection, see SelectionMode and TreeView,SelectedNodes, this has always been a struggle in WinForms.
  • Tiago (ITG)
    BoundTreeView supports SelectNode = null. I plan to do nothing, meaning let the OnEVENT flow and always call base.OnEVENT(e). I just need Wisej not to raise NullReferenceException on base.OnEVENT(e).
  • You must to post comments
0
0

Here is the attachement.

  • You must to post comments
0
0

I can reproduce the null exception. It’s WJ-8406.

Non selecting the first node is by design. That behavior in WinForms has always created problems with the selection events and having to set the node to null.

  • Luca (ITG)
    Forgot to add that OnBefore/AfterSelect are fired also when setting SelectedNode = null to let the code cancel the event or handle the event when clearing a selection.
  • Luca (ITG)
    And that it’s actually a regression added when we replicated the TreeView node event to the TreeNode element, a new feature.
  • You must to post comments
0
0

Hi Tiago, the attachment is missing.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.