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
1705
How do I access the text that's NOT selected?
posted

I have a combo with DropDownSearchMethod = Default.  As the user types, the combo does a search on the user's text.  Characters typed by the user are unselected, characters matched by the combo are selected.  How do I access the unselected text in the box?

The combo.TextBox.Text property is the complete text; user entered and searched.  SelectedText = "", SelectionStart = the last character and SelectionLength = 0.  Not very helpful!

  • 69832
    Offline posted

    The SelectionStart and SelectionLength properties of the TextBox describe the text selection. In the case where SelectionStart = 0, the unselected text is the substring between (SelectionLength - 1) and (Text.Length - 1). When SelectionStart > 0, you will have two strings, (0 to SelectionStart to SelectionStart) and ([SelectionLength - SelectionStart] to Text.Length - 1).