Hi
I'm using an UltraCombo with a BindingList bound to it.
I'd like to implement my own AutoCompletion feature. Therefore I've set the AutoCompleteMode to None, on KeyDown, the Combo is dropped down explicitly having the appropriate column filters set.
This works fine, but when the combo is dropped down, the so far entered text in the textbox is completely selected. It would be nicer if the caret would maintain its position, so that the user is can continue typing without overwriting the text portion he already entered.
I've already tried to override this behaviour by clearing the text selection and setting the caret to the end in the AfterDropDown event. But this does not help.
Is there another way to do this?
Thanks in advance!
This is probably just an issue of timing. Try this:
private void ultraCombo1_AfterDropDown(object sender, EventArgs e) { this.BeginInvoke(new MethodInvoker(this.SetSelection)); } private void SetSelection() { this.ultraCombo1.Textbox.SelectionLength = 0; this.ultraCombo1.Textbox.SelectionStart = this.ultraCombo1.Textbox.Text.Length; }
Hello,
In the example posted above, why not just call the SetSelection method directly instead of through the MethodInvoker call?
Because the control sets the selection after the event fires. So anything you do directly inside the event will be overriden by the control behavior. The BeginInvoke institutes a delay so that the code does not get executed until the control processing is done.
Thanks for the explanation. Is the MethodInvoker method required for all events, some, etc? How do you know when to use it?
It's not requires except in circumstances where timing issues occur which prevent you from doing what you want to do.It's essentially a workaround to a problem that was simply not anticipated when the grid was originally developed.