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;
I don't think there is a property, no.
You can Submit a feature request to Infragistics
Do you know how I can highlight the text in the editor control when the user clicks into it for the first time? i.e. the control does not have focus and the user clicks.
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?
Couldn't you just use SelectAll() in the Enter event? I tried that here and it works fine.
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.
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 tried using the BeginInvoke method but that still did not work.
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.