0

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.

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;
}

The TreeView has similar events like this treeview from WinForms plus some more.

  • Looks like there is no documentation for that controls (seems they already died actually) but you might need to subscribe to a `validating` event or something like that (maybe something like `TreeNodeCreated`) so you might be able to handle the moment just after the user commited the change. – Gonzo345 Jul 24 '18 at 10:04
  • @Gonzo345 yes I've also seen that they declared this product End of Life :D (I'm working on already existing source, might need refactoring …. ). Do you know how I can subscribe to such an event? I think I have a working method which checks everything but I don't know how I can create an event handler for it.... It shouldn't allow the user to leave the edit mode (by pressing Enter) – Markus Rechberger Jul 24 '18 at 10:33
  • Which events has the control? List them updating your question and let's see how could we attack it! – Gonzo345 Jul 24 '18 at 11:00
  • @Gonzo345 If I'd list all events Visual Studio shows me when typing mTreeView. I'd be typing until tomorrow. That's why I added a link to the TreeView of WinForms which has a lot of events in common (I just saw many more in the Crownwood thing)…. I hope this is ok – Markus Rechberger Jul 24 '18 at 11:36

0 Answers0