[resolved] Combobox Autofind
We have severe issues with the combobox control in .Net 2003 at work. Basically when you type in something in the combobox it will look like the combobox finds the matching item, but it doesn't. I'm trying to write some AutoFind code to fix this.
VB Code:
Private Sub cmb_KeyUp _
( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs _
) Handles cmb.KeyUp
Call Me.SelectComboboxItem(sender)
e.Handled = True
End Sub
Private Sub SelectComboboxItem(ByVal p_cmb As ComboBox)
Dim retVal As Integer
Dim txtLen As Integer
txtLen = p_cmb.Text.Length
p_cmb.Tag = p_cmb.Text
retVal = p_cmb.FindString(p_cmb.Text)
If retVal <> -1 Then
p_cmb.SelectedIndex = retVal
'code below is ignored, entire text is selected
p_cmb.SelectionStart = txtLen
p_cmb.SelectionLength = p_cmb.Text.Length - txtLen
End If
End Sub
Everything works except the SelectionStart and SelectLength parts. The properties change but when the code actually runs the entire text is selected instead of just selecting the letters that were filled in for the user. Anyone have any ideas on how to make this functionality work?