We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Force TreeViewAdv node to stay in edit mode

Thread ID:

Created:

Updated:

Platform:

Replies:

38938 Dec 21,2005 11:09 AM Dec 22,2005 09:31 AM Windows Forms 2
loading
Tags: Tools
Jon Zucker
Asked On December 21, 2005 11:09 AM

How can I force a tree node to stay in edit mode? After I add a new node to a tree, I invoke TreeViewAdv.BeginEdit(MyNewNode) to force the user to type in a new name for the node. I also use the NodeEditorValidating event handler to ensure that the name is unique. My event handler looks like this: if (NewNameIsNotUnique(e.Label)) { MessageBox.Show(“Name is not unique”); TreeViewAdv.BeginEdit(e.Node); } What I’m trying to do is to leave the node in editing mode until the user enters a unique name. But instead, when the event handler exits, the node leaves editing mode. This can leave a non-unique node name (which is bad for me). The BeginEdit method doesn’t seem to have any effect. The node is no longer in edit mode when this function completes. If I invoke TreeViewAdv.EndEdit(false) before calling BeginEdit (or instead of calling BeginEdit), then the NodeEditorValidating function is reinvoked in an infinite loop. Any ideas on how to keep the user from leaving a node that’s in edit mode until they’ve entered a valid (in my case, that means unique) node name?

Deepa TS [Syncfusion]
Replied On December 22, 2005 04:30 AM

Hi Jzucker, Please refer to the sample attached with this, that shows how you could accomplish the above by handling the TreeViewAdv''s NodeEditorValidating eventas shown below : private void treeViewAdv1_NodeEditorValidating_1(object sender, Syncfusion.Windows.Forms.Tools.TreeNodeAdvCancelableEditEventArgs e) { if(e.Label=="Syncfusion") { e.Cancel = false; MessageBox.Show("Unique"); e.ContinueEditing = false; } else { // Cancel the label edit action, inform the user, and place the node in edit mode again. // e.Cancel = true; MessageBox.Show("Name is not unique"); // To end editing mode, do this: e.ContinueEditing = true; } } Let me know if this meets your requirements. Thanks for your continued interest in Syncfusion products. Regards, Deepa.T.S

test13.zip

Jon Zucker
Replied On December 22, 2005 09:31 AM

Well, it sort of works. When I run the sample code in the sample project you provided, it works perfectly. But when I use the same code in my own project, I still get stuck in an infinite loop. The tree''s NodeEditorValidating event is fired again after I exit the event handler, but I don''t know why. I''m still looking into that. Thanks for your help.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;