Now I see you were talking about the Node Labels, ok, about this:
but guess what, if your editing a label and after the LostFocus event gets hit initially, it never gets hit again when the control ACTUALLY DOES LOOSE FOCUS
This is not true, the Lost_Focus event always fires, but if you stop the code in AfterLabelEdit for example adding a breakpoint in this event, then Lost_Focus event won't fire, but this only happens when debbuging in VB IDE and you stop execution. For example, as a test, printing each event to Form when they occur, don't add breakpoints in code:
Code:
Private Sub TreeView1_AfterLabelEdit(Cancel As Integer, NewString As String)
Me.Print "TreeView1_AfterLabelEdit"
End Sub
Private Sub TreeView1_BeforeLabelEdit(Cancel As Integer)
Me.Cls
Me.Print "TreeView1_BeforeLabelEdit"
End Sub
Private Sub TreeView1_LostFocus()
Me.Print "TreeView1_LostFocus"
End Sub
So simply using a boolean variable, setting it to true on BeforeLabelEdit and cheking it's value when LostFocus() triggers should be enough for the particular case when the user moves focus away from the Treeview.
Also as an alternative, you have Validate event, that fires before LostFocus() event.
You're right about the other problem about AfterLabelEdit not firing when the label is edited and no change is done, there is no event fired when this happen. If you need to solve this particular case i think a good idea would be in the Hook process (you need to hook the Treeview) debug.print all messages processed by the control and see what messages are triggered just when you exit editing a label without making changes, you'll just see numbers in the debug window but one of them should be what you need.