Amit Shah
Amit Shah

Reputation: 327

Disabling Collapse event of a root node in Treeview in .NET

I am developing a application in which i need to prevent collapsable behaviour of a root node in tree view. I tried using Before Select event. Is there any alternative for it?

Upvotes: 2

Views: 1281

Answers (1)

max
max

Reputation: 34407

You need BeforeCollapse event:

private void OnBeforeCollapse(object sender, TreeViewCancelEventArgs e)
{
    if(!CanCollapse(e.Node)) e.Cancel = true;
}

It assumes you have a CanCollapse function, which determines if node can be collapsed.

Upvotes: 3

Related Questions