验证和调整树视图标签

时间:2023-01-31 23:16:55

I've got a treeview control, and have caught its after-label-edit event. I want to be able to validate the user's input and adjust it - if for instance it's too long - but I only seem able to cancel the new value, not change it. Any ideas?

我有一个treeview控件,并且已经捕获了它的标签后编辑事件。我希望能够验证用户的输入并进行调整 - 例如,如果它太长 - 但我似乎只能取消新值,而不是更改它。有任何想法吗?

I don't want to have to open a new form, the user might be renaming a range of these and it shouldn't be too cumbersome.

我不想打开一个新表单,用户可能会重命名这些表单并且它不应该太麻烦。

Cheers.

1 个解决方案

#1


1  

Can't you get the node being edited from the EventArgs, and manually set its text? If this causes the AfterLabelEdit to be fired again, then you should add a flag to exit it if it comes from a manual edit.

你不能从EventArgs获得正在编辑的节点,并手动设置其文本吗?如果这导致AfterLabelEdit再次被触发,那么如果它来自手动编辑,则应添加一个标志以退出它。

#1


1  

Can't you get the node being edited from the EventArgs, and manually set its text? If this causes the AfterLabelEdit to be fired again, then you should add a flag to exit it if it comes from a manual edit.

你不能从EventArgs获得正在编辑的节点,并手动设置其文本吗?如果这导致AfterLabelEdit再次被触发,那么如果它来自手动编辑,则应添加一个标志以退出它。