this is the easiest way, but it works for me with the name ComboBox1
SOLUTION on 3 main elements:
step 1.
Declare a variable at the beginning of the form that will contain the original text value of the ComboBox. Example:
Dim xCurrentTextValue as string
Step 2
Create a combobox1 key down event and set xCurrentTextValue to the current combobox text; if a key other than "ENTER" is pressed, the combobox text value retains the original text value
Example:
Private Sub ComboBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles ComboBox1.KeyDown xCurrentTextValue = ComboBox1.Text If e.KeyCode <> Keys.Enter Then Me.ComboBox1.Text = xCmbItem End If End Sub
Step 3
Confirm when the combined text changes if len (xcurrenttextvalue)> 0 or differs from nothing, then combobox1 takes the value of the variable xcurrenttextvalue
Private Sub ComboBox1_TextChanged(sender As Object, e As EventArgs) Handles ComboBox1.TextChanged If Len(xCurrentTextValue) > 0 Then Me.ComboBox1.Text = xCurrentTextValue End If End Sub
==================================================== ======== what is he,
Initially, I only tried step number 2, but I have problems when you press the DEL key and the down arrow, also for some reason it did not confirm the keydown event if I do not show any message box
! Sorry, this fix is ββin step number 2, I forgot to change the xCmbItem variable to xCurrentTextValue, xCmbItem, which was used for my personal use
THIS IS THE RIGHT CODE
xCurrentTextValue = ComboBox1.Text If e.KeyCode <> Keys.Enter Then Me.ComboBox1.Text = xCurrentTextValue End If
rgvpctech May 18 '13 at 5:15 a.m. 2013-05-18 05:15
source share