I have an inherited comboBox that I'm using to try to make an intellisense type box in VS 2003 .Net.
It works okay in VS.Net 2002. I can get it to do most of my stuff, but it's not keeping the SelectionStart and SelectionLength values I assign in my OnKeyPress event.
Here is a snippet of my code. The Application.DoEvents() funcs are just so I can see what's going on at various spots.
private void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) {
string _cmbText;
int selectionStart;
int selectionLength;
AutoComboBox _cmb = (AutoComboBox) sender;
if (_cmb.DropDownStyle == System.Windows.Forms.ComboBoxStyle.DropDown ||
_cmb.DropDownStyle == System.Windows.Forms.ComboBoxStyle.Simple) {
_cmbText = SearchList(_cmb); //this returns the Text at the index of the combobox from the FindText(string) func
if (_cmbText != String.Empty) {
selectionStart = _cmb.Text.Length;
selectionLength = _cmbText.Length - _cmb.Text.Length;
_cmb.SelectedIndex = _cmb.FindString(_cmbText);
_cmb.SelectionStart = selectionStart;
_cmb.SelectionLength = selectionLength;
e.Handled = true;
}
}
}