Disabling Collapse event of a root node in Treeview in .NET
I am developing a application in which i need to prevent collap开发者_开发知识库sable behaviour of a root node in tree view. I tried using Before Select event. Is there any alternative for it?
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.
精彩评论