I've tried unsuccessfully to get a UltraTreeNode to stay in edit mode (of the node label itself), after a user makes an edit.
What I've tried is to use the AfterLabelEdit event to check whether the node's name is acceptable via some routine and if not to try and keep the label in edit mode. I've tried calling PerformAction(UltraTreeAction.EnterEditMode, false, false) from within the AfterLabelEdit handler, but this doesn't seem to work.
Any ideas?
this.ultraTree1.Override.Editor = new EditorWithText();this.ultraTree1.EditorResolved.BeforeExitEditMode += new BeforeExitEditModeEventHandler(EditorResolved_BeforeExitEditMode);
private void EditorResolved_BeforeExitEditMode(object sender, BeforeExitEditModeEventArgs e){ EmbeddableEditorBase editor = sender as EmbeddableEditorBase;
if ( editor != null ) { if ( string.Equals(editor.CurrentEditText, "foo") == false ) { MessageBox.Show( "Invalid" ); e.Cancel = true; } }}
If you add a node, don't type anything into it and press return, the event does not fire.
Perhaps I am not understanding your request. Please clarify why the following approach does not solve the problem:
private void ultraTree1_ValidateLabelEdit(object sender, ValidateLabelEditEventArgs e){ if ( string.Equals(e.LabelEditText, "foo") == false ) { MessageBox.Show( "Invalid" ); e.StayInEditMode = true; }}
Hi,
after much scratching of head, it appears that this event doesn't get fired unless the user pressed a key, now in normal circumstances, that's ok, as we can supply a sensible default. The problem which is causing an issue, is that there is a possibility that an error could occur when the default text is used (failure to save data to server etc) the result of which I would like to be able to raise a message and force the node back into edit mode, is there any way to acheive that?
Thanks,
Chris
Use the ValidateLabelEdit event.