By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 2,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

Up/Down keys do not work with AutoComplete SuggestAppend textbox

P: 3
I have a textbox in a DataGridView and I use the following code to AutoComplete, SuggestAppend. It appears to work OK apart from the fact that when the dropdown list appears, I cannot use the Up/Down keys to scroll through the list and I have to use the mouse to make a selection. If I click the Up/Down keys or if I lick anywhere on the screen outside the textbox and dropdown list the first item of the list is selected.

Please help. It is driving me crazy.
John

Expand|Select|Wrap|Line Numbers
  1. Private Sub dgvAppointment_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles dgvAppointment.EditingControlShowing
  2.  
  3.  
  4.         If (dgvAppointment.CurrentCell.ColumnIndex = DFN_GRID_intPatientID_COL) Then
  5.             ItemCode = TryCast(e.Control, TextBox)
  6.             ItemCode.Name = "textbox1"
  7.             AddHandler ItemCode.TextChanged, AddressOf ItemCode_Changed
  8.             AddHandler ItemCode.PreviewKeyDown, AddressOf ItemCode_PreviewKeyDown
  9.             namesCollection.Add("")
  10.             If ItemCode IsNot Nothing Then
  11.                 If dgvAppointment.CurrentCell.ColumnIndex = DFN_GRID_intPatientID_COL Then
  12.                     With DirectCast(e.Control, TextBox)
  13.                         .AutoCompleteMode = AutoCompleteMode.SuggestAppend
  14.                         .AutoCompleteSource = AutoCompleteSource.CustomSource
  15.                         .AutoCompleteCustomSource = namesCollection
  16.                     End With
  17.                 Else
  18.                     With DirectCast(e.Control, TextBox)
  19.                         .AutoCompleteMode = AutoCompleteMode.None
  20.                     End With
  21.                 End If
  22.             End If
  23.         End If
  24.     End Sub
  25.  
  26.     Private Sub ItemCode_Changed(sender As Object, e As EventArgs)
  27.  
  28.         Me.txtCounter.Text = CStr(CInt(Me.txtCounter.Text) + 1)
  29.  
  30.         Dim textbox As TextBox = TryCast(sender, TextBox)
  31.         Try
  32.             If textbox.TextLength = 0 Then
  33.                 intmTextLength = -1
  34.             End If
  35.  
  36.             If (intmTextLength = -1) Or (System.Math.Abs(textbox.TextLength - intmTextLength) = 1) Then
  37.                 intmTextLength = textbox.TextLength
  38.                 GetPatientByLastFirstTel(textbox.Text)
  39.             Else
  40.  
  41.             End If
  42.  
  43.         Catch ex As Exception
  44.  
  45.         End Try
  46.     End Sub
Apr 17 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.