Tuesday, October 18, 2016

Disable select all text highlighting when using combobox in WPF

        private void MyComboBox_DropDownOpened(object sender, EventArgs e)
        {
            TextBox textBox = (TextBox)((ComboBox)sender).Template.FindName("PART_EditableTextBox", (ComboBox)sender);
            textBox.SelectionStart = ((ComboBox)sender).Text.Length;
            textBox.SelectionLength = 0;
        }

Reference:

http://stackoverflow.com/questions/1441645/wpf-dropdown-of-a-combobox-highlightes-the-text

http://stackoverflow.com/questions/3667275/remove-select-all-from-combobox-wpf

No comments: