' Declare an EditorWithCombo variable
Private editor As EditorWithCombo = Nothing
' Handles the UltraTree control's AfterActivate event, to fire the SelectionChanged event of the EditorWithCombo associated with the ActiveNode.
Private Sub ultraTree1_AfterActivate(ByVal sender As Object, ByVal e As NodeEventArgs) Handles ultraTree1. AfterActivate
Dim node As UltraTreeNode = e.TreeNode
If node Is Nothing Then
Exit Sub
End If
Dim editor_Combo As EditorWithCombo = TryCast(node.EditorResolved, EditorWithCombo)
' If the editor hasn't changed since the last time we did this, return since we are already listening to the right editor's event
If Me.editor = editor_Combo Then
Exit Sub
End If
' If we have a non-null editor reference, unhook its SelectionChanged event
' (This loop is executed if the previous selection was a different editor)
If Me.editor IsNot Nothing Then
RemoveHandler Me.editor.SelectionChanged, AddressOf Me.editor_SelectionChanged
Me.editor = Nothing
End If
' Set our reference
Me.editor = editor_Combo
' Wire the event on the new editor
AddHandler Me.editor.SelectionChanged, AddressOf Me.editor_SelectionChanged
End Sub
' Handles the EditorWithCombo's SelectionChanged event.
Private Sub editor_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs) Handles editor.SelectionChanged
Dim editor As EditorWithCombo = TryCast(sender, EditorWithCombo)
Dim val As Object = editor.Value
End Sub