AIM: During rename of UltraTreeNode text
a)Press 'Enter' key: Remain in edit mode only (conditionally)
b)Press 'ESC' key: Come out of edit mode and UltraTreeNode text is not changed. It remains original node text.
Problem:
Edit UltraTreeNode text, press 'ESC' Key: works fine. UltraTreeNode text is original text.
Edit UltraTreeNode text, press 'Enter' Key, press ESC key. UltraTreeNode text becomes new text.
Question 1: Why ESC key after (Enter key + StayInEditMode = true) makes UltraTreeNode as new text.?
Question 2: Why (e.OriginalText == null)? in function ValidateLabelEdit on pressing Enter Key 2nd time?
Looks like after going through (Enter key + StayInEditMode) route, the e.OriginalText looses its value and that could be reason for ESC key making UltraTreeNode text as new text.
Details:
- - - - - - - - - - - -
Case 1: (Works fine)
1) UltraTreeNode.BeginEdit(). Changed UltraTreeNode text.
2) Press 'Escape' key. UltraTreeNode text changes back to OriginalText.
Works fine.
Case 2: (Problem)
2) User presses 'Enter' Key. In Function ValidateLabelEdit
e.StayInEditMode =
true;
is called. (User remains in edit mode only)
3) Press 'Escape' key. UltraTreeNode text changes to new text.
Case 3: (one observation)
e.OriginalText !=
null, it contains the original text. Good.
3) User presses 'Enter' Key. In Function ValidateLabelEdit
e.OriginalText =
null, it no more contains the original text. Observation.
This could be the reason that pressing ESC key after pressing Enter key had make the node text empty.
Source Code:
____________________________________________________
namespace UltraTree{ public partial class MyUltraTreeForm : Form { public MyUltraTreeForm() { InitializeComponent(); this.MyultraTree.Override.UseEditor = Infragistics.Win.DefaultableBoolean.True; this.MyultraTree.ValidateLabelEdit += new Infragistics.Win.UltraWinTree.ValidateLabelEditEventHandler(this.MyultraTree_ValidateLabelEdit); this.MyultraTree.ExpandAll(); this.MyultraTree.ActiveNode = this.MyultraTree.Nodes[0].Nodes[0]; }
private void EditNodeA_Click(object sender, EventArgs e) { this.MyultraTree.ActiveNode.BeginEdit(); }
private void MyultraTree_ValidateLabelEdit(object sender, Infragistics.Win.UltraWinTree.ValidateLabelEditEventArgs e) { EditorWithText editor = (EditorWithText)e.Node.EditorResolved; if (e.OriginalText == null) { // Error Infragistics.Win.UltraMessageBox.UltraMessageBoxManager.Show("e.OriginalText is empty"); }
e.StayInEditMode = true; //e.LabelEditText = // This I dont want to do. } }}
__________________________________________________
Hi,
Setting e.StayInEditMode keeps the node in edit mode, but it does not stop the new text from being committed to the node.To do that, you also need to set e.Cancel to true. This seems to give me the behavior you want:
private void ultraTree1_ValidateLabelEdit(object sender, Infragistics.Win.UltraWinTree.ValidateLabelEditEventArgs e) { if (string.IsNullOrEmpty(e.LabelEditText)) { e.Cancel = true; e.StayInEditMode = true; } }
Thanks you, it is working perfectly after
e.Cancel =
/* Probably I though too much to solve this that though I did try
but because e.OriginalText == null was still happening on 2nd call to
function ValidateLabelEdit that I really missed to see that problem is solved if I use e.Cancel = true and had removed this line.
*/
solved, but purely curiosity sake - why e.OriginalText == null still happens on 2nd call to ValidateLabelEdit?
Hello Vikas,
Which version of NetAdvantage are you using? Also, which version of Visual Studio are you using?
Thank you.
I have logged this as a development issue with an ID# of 101359. I will make another post once the issue has been resolved.
NetAdvantage2010.3 for WinForms
MSVS 2010 .net 4.0 Windows XP Professional