I'm using the UltrNumericEditor control on a form, but all the text is not selected when I tab into or click into the control. Does anyone know how I can get it to select all of the text when the user tabs into it or clicks into it with them mouse?
Try this thread:
Select text when tabbing in MaskedEdit - Infragistics Forums
Mike,
I created the following event handler for highlighting the text when the user tabs into the control. I created another event handler for the MouseDobubleClick event that makes a call the the same HighLightEditor text method. This solves the problem. Do you know if the control has a property to handle this? I think the control should be able to do this automatically.
{
this.HighlightEditorText(((UltraNumericEditor)sender).Editor);
}
private void HighlightEditorText(Infragistics.Win.EmbeddableEditorBase editor)
if (editor.Value != null) { string str = editor.Value.ToString(); editor.SelectionStart = editor.TextLength - str.Length; editor.SelectionLength = str.Length;
string str = editor.Value.ToString(); editor.SelectionStart = editor.TextLength - str.Length; editor.SelectionLength = str.Length;
editor.SelectionStart = editor.TextLength - str.Length;
editor.SelectionLength = str.Length;
This same code is called when the cotrol is clicked, however, the text in the control is not being highlighted like it is when you tab into the control. Please explain why I'm getting different results from the same piece of code?
This is probably because the control responds to the mouse and positions the cursor at the point that was clicked. This likely happens after the Enter event fires. So your code to select all the text is probably working, it's just getting overriden by the native behavior of the control.
You can usually get around stuff like this by calling your SelectAll method using a BeginInvoke instead of calling it directly.
I tried using the BeginInvoke method but that still did not work.
I just testing this out and it works fine for me.
private void ultraNumericEditor1_Enter(object sender, EventArgs e) { this.BeginInvoke(new MethodInvoker(this.ultraNumericEditor1.SelectAll)); }
If it's not working for you, then you should Submit an incident to Infragistics Developer Support and send them a small sample project demonstraing it so they can check it out.
I was using the wrong event. I was using the AfterEnterEditMode event which does not get fired when the user clicks into the control with the mouse.
Couldn't you just use SelectAll() in the Enter event? I tried that here and it works fine.