Treeview - 禁止空节点重命名 [英] Treeview - forbid empty node rename

查看:135
本文介绍了Treeview - 禁止空节点重命名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TreeView(使用Crownwood.DotNetMagic,它应该类似于WinForms),当用户编辑节点时,当文本为空时,不应允许他离开编辑模式。



TreeView有类似的事件,如来自WinForms的这个树视图



我尝试了什么:



我尝试在我的AfterLabelEdit中执行此操作,但它并不完全符合我的要求:它将文本设置回原始文本但我希望它在编辑模式下保持为空(用户)应该不允许提交他的更改)

I have a TreeView (using Crownwood.DotNetMagic, it should be similar to WinForms) and when the user edits a node, he should not be allowed to leave the edit mode when the text is empty.

The TreeView has similar events like this treeview from WinForms

What I have tried:

I've tried doing this in my AfterLabelEdit but it doesn't exactly do what I want: It sets the text back to the original text but I want it to stay empty in the edit mode (the user should just not be allowed to commit his changes)

if (String.IsNullOrEmpty(e.Label))
{
    e.Cancel = true;
    e.Node.BeginEdit();
    return;
}

推荐答案

通过PF Key创建添加节点,删除和重命名/替换节点功能,按钮等,并提示所需的数据应用于树视图/节点。



如果你保持树视图的控制,你的生活会更简单维护过程,而不是猜测用户在移动后可能尝试做什么。
Create an "add node", delete and a "rename / replace" node function via a PF Key, button etc, and prompt for the required data to apply to the tree view / node.

Your life will be simpler if you maintain "control" of the tree view maintenance process instead of guessing what the user might be trying to do after they've made a move.


这篇关于Treeview - 禁止空节点重命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆