Why does the combobox using the keyboard up & down arrows not reflect the textbox in vb.net.
So I want the up and down arrows on the keyboard to still appear in the textbox
I use the String.Equals Method to check the value selected in the combox is correct or not by referring to the textbox.
Please Guide Me
Thanks
Public Class Form4
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
ComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
ComboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
End Sub
Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox1.AutoCompleteCustomSource = AutoSuggestList()
End Sub
Private Function AutoSuggestList() As AutoCompleteStringCollection
Dim collection As New AutoCompleteStringCollection
Using connection As New OleDbConnection(GetOledbConnectionString())
collection.AddRange(connection.Query(Of String)("SELECT ColorCode FROM ColorCode").ToArray)
End Using
Return collection
End Function
Private Sub GetItemData(ByVal iditem As String)
Dim item = COLORCODESERVICE.GetByColorcode2(iditem)
If item IsNot Nothing Then
If String.Equals(iditem, item.Colorcode, StringComparison.CurrentCultureIgnoreCase) Then
ComboBox1.Text = item.Colorcode
End If
TextBox1.Text = item.Colorname
ComboBox1.Text = item.Colorcode
Else
MsgBox("Not Found Colorcode...")
ComboBox1.ResetText()
TextBox1.Clear()
Return
End If
End Sub
Private Sub ComboBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles ComboBox1.KeyDown
If e.KeyCode = Keys.Enter OrElse e.KeyCode = Keys.Up OrElse e.KeyCode = Keys.Down Then
ComboBox1.Items.Add(ComboBox1.Text)
GetItemData(ComboBox1.Text)
ElseIf e.KeyCode = Keys.Back OrElse e.KeyCode = Keys.Delete Then
ComboBox1.ResetText()
TextBox1.Clear()
End If
End Sub
Private Sub ComboBox1_TextUpdate(sender As Object, e As EventArgs) Handles ComboBox1.TextUpdate
TextBox1.Clear()
End Sub
End Class
