Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
305
Clear text selection after DropDown
posted

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!

Parents
  • 469350
    Verified Answer
    Offline posted

    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;
            }

Reply Children