Make Windows Form TreeView Node Not Clickable using C# and VB.Net

Last Reply 6 months ago By dharmendr

Posted 6 months ago

Make TreeView Node Not Clickable in ASP.Net

SelectAction = TreeNodeSelectAction.None 

given above code is not working in wndows treeview

please suggest for windows application perform the same task

You are viewing reply posted by: dharmendr 6 months ago.
Posted 6 months ago

Hi aspvijay04,

I am assuming you don't want TreeView node to be selectable.

You can do with BeforeSelect event and you can cancel it.

For using TreeView in Windows Application refer below article.

Populate TreeView from Database in Windows Forms using C# and VB.Net

C#

private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
{
    e.Cancel = true;
}

VB.Net

Private Sub treeView1_BeforeSelect(sender As System.Object, e As System.Windows.Forms.TreeViewCancelEventArgs) Handles treeView1.BeforeSelect
    e.Cancel = True
End Sub

Screenshot