C# – Why isn’t there a SelectedNodeChanged event for Windows.Forms.TreeView

cnettreeviewwinforms

The System.Web.UI.WebControls.TreeView class offers this event, but the Forms version of TreeView doesn't. What's the equivalent in the Forms world? I'm using AfterSelect but it doesn't seem quite right. Maybe it is in fact what I'm looking for but the documentation is a bit hazy.

Best Answer

There's none in WinForms TreeView. To quote MSDN for TreeView.AfterSelect:

This event does not occur when the node is unselected. To detect this occurrence, handle the Control.MouseUp event and test the TreeNode.IsSelected property.

Yes, this sucks.