开发者

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

开发者 https://www.devze.com 2023-01-02 06:50 出处:网络
I am developing a application in which i need to prevent collap开发者_开发知识库sable behaviour of a root node in tree view.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消