T
ToddT
the following code snippet implements an "auto complete" functionality
for combo boxes. it works fine on all the developer's computers but
only selects the first item in the combo box on non-developer's
computers. what kind of workstation configuration difference could
cause this kind of problem? i'm at a lost...
Private Sub cboCountry_KeyPress(ByVal sender As System.Object, ByVal
keyPressArgs As System.Windows.Forms.KeyPressEventArgs) Handles
cboCountry.KeyPress
Dim keyCode As Integer
Dim index As Integer
Dim searchString As String
keyCode = Convert.ToInt32(keyPressArgs.KeyChar)
Select Case(keyCode)
Case Keys.PageDown
<snip>
' Scroll the scrollable panel up
Case Keys.PageUp
<snip>
Case Keys.Down, Keys.Up, Keys.Back, Keys.Right, Keys.Left
<snip>
Case Else
searchString = cboCountry.Text
index = cboCountry.FindString(searchString)
If (index >= 0) Then
cboCountry.SelectedIndex = index
cboCountry.SelectionStart = searchString.Length
cboCountry.SelectionLength =
cboCountry.Text.Length - cbo.SelectionStart
previousIndex = index
Else
cboCountry.SelectedIndex = previousIndex
cboCountry.SelectionStart =
searchString.Length - 1
cboCountry.SelectionLength =
cboCountry.Text.Length - cboCountry.SelectionStart
End If
keyPressArgs.Handled = True
End Select
End Sub ' cbo_KeyPress()
for combo boxes. it works fine on all the developer's computers but
only selects the first item in the combo box on non-developer's
computers. what kind of workstation configuration difference could
cause this kind of problem? i'm at a lost...
Private Sub cboCountry_KeyPress(ByVal sender As System.Object, ByVal
keyPressArgs As System.Windows.Forms.KeyPressEventArgs) Handles
cboCountry.KeyPress
Dim keyCode As Integer
Dim index As Integer
Dim searchString As String
keyCode = Convert.ToInt32(keyPressArgs.KeyChar)
Select Case(keyCode)
Case Keys.PageDown
<snip>
' Scroll the scrollable panel up
Case Keys.PageUp
<snip>
Case Keys.Down, Keys.Up, Keys.Back, Keys.Right, Keys.Left
<snip>
Case Else
searchString = cboCountry.Text
index = cboCountry.FindString(searchString)
If (index >= 0) Then
cboCountry.SelectedIndex = index
cboCountry.SelectionStart = searchString.Length
cboCountry.SelectionLength =
cboCountry.Text.Length - cbo.SelectionStart
previousIndex = index
Else
cboCountry.SelectedIndex = previousIndex
cboCountry.SelectionStart =
searchString.Length - 1
cboCountry.SelectionLength =
cboCountry.Text.Length - cboCountry.SelectionStart
End If
keyPressArgs.Handled = True
End Select
End Sub ' cbo_KeyPress()