About the combobox textchange event
-
Dear all, I'm new to this VB.NET,my platform using now to do the development is Visual Studio 2008 using the VB.NET 2008 Window Form to create a lorry transportation management system. I'm facing problem with the combobox textchange event now. I'm using MySQL 5.0 with SQLYog v5.29 to develop this system. The following is a form code for the user to insert the Delivery Order document:
Imports MySql.Data.MySqlClient
Public Class InputDO
Public Shared MyConnString As String = "Server=;Database=logistic_sysdb;Uid=root;Pwd=;"
Public Shared ObjMyConn As New MySqlConnection
Public Shared ObjComm As New MySqlCommand
Public Shared ObjRead As MySqlDataReader
Public Shared SQL As StringDim ObjAdapter As MySqlDataAdapter Dim ds As DataSet Dim dt As DataTable Dim dt1 As DataTable Private Sub InputDO\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer ObjMyConn = New MySqlConnection(MyConnString) 'Load the information into Lorry Number Combobox Try SQL = "SELECT \* FROM lorry\_detail" ds = New DataSet ObjAdapter = New MySqlDataAdapter(SQL, ObjMyConn) ObjAdapter.Fill(ds, "Lorry\_Number") dt = ds.Tables("Lorry\_Number") For i = 0 To dt.Rows.Count - 1 ComboBox1.Items.Add(dt.Rows(i).Item(0)) Next Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!") End Try Try SQL = "SELECT \* FROM company\_detail" ds = New DataSet ObjAdapter = New MySqlDataAdapter(SQL, ObjMyConn) ObjAdapter.Fill(ds, "Client\_Company") dt1 = ds.Tables("Client\_Company") Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!") End Try End Sub Private Sub ComboBox2\_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox2.TextChanged Dim x As String ' x = The Client Company name that stored at dt1 Dim i As Integer x = ComboBox2.Text For i = 0 To dt1.Rows.Count - 1 If x = dt1.Rows(i).Item(1) Then ComboBox2.Items.Add(dt1.Rows(i).Item(1)) End If Next End Sub
End Class
I would like to show the similar
-
Dear all, I'm new to this VB.NET,my platform using now to do the development is Visual Studio 2008 using the VB.NET 2008 Window Form to create a lorry transportation management system. I'm facing problem with the combobox textchange event now. I'm using MySQL 5.0 with SQLYog v5.29 to develop this system. The following is a form code for the user to insert the Delivery Order document:
Imports MySql.Data.MySqlClient
Public Class InputDO
Public Shared MyConnString As String = "Server=;Database=logistic_sysdb;Uid=root;Pwd=;"
Public Shared ObjMyConn As New MySqlConnection
Public Shared ObjComm As New MySqlCommand
Public Shared ObjRead As MySqlDataReader
Public Shared SQL As StringDim ObjAdapter As MySqlDataAdapter Dim ds As DataSet Dim dt As DataTable Dim dt1 As DataTable Private Sub InputDO\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer ObjMyConn = New MySqlConnection(MyConnString) 'Load the information into Lorry Number Combobox Try SQL = "SELECT \* FROM lorry\_detail" ds = New DataSet ObjAdapter = New MySqlDataAdapter(SQL, ObjMyConn) ObjAdapter.Fill(ds, "Lorry\_Number") dt = ds.Tables("Lorry\_Number") For i = 0 To dt.Rows.Count - 1 ComboBox1.Items.Add(dt.Rows(i).Item(0)) Next Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!") End Try Try SQL = "SELECT \* FROM company\_detail" ds = New DataSet ObjAdapter = New MySqlDataAdapter(SQL, ObjMyConn) ObjAdapter.Fill(ds, "Client\_Company") dt1 = ds.Tables("Client\_Company") Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!") End Try End Sub Private Sub ComboBox2\_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox2.TextChanged Dim x As String ' x = The Client Company name that stored at dt1 Dim i As Integer x = ComboBox2.Text For i = 0 To dt1.Rows.Count - 1 If x = dt1.Rows(i).Item(1) Then ComboBox2.Items.Add(dt1.Rows(i).Item(1)) End If Next End Sub
End Class
I would like to show the similar
drexler_kk wrote:
I have select all the client company into dt1 from the database,and now how could I check if the user is typing each character into combobox2 will display the similar company name on the combobox?
I am not sure if I understand your question Do you want to auto search (Auto Complete) the results from the combobox? Meaning when you press 'A', it will fetch all the combo items starting with 'A' and so on.
Mubashir Senior Engineer Storan Technologies Inc, USA Every job is a self portrait of the person who did it.
-
drexler_kk wrote:
I have select all the client company into dt1 from the database,and now how could I check if the user is typing each character into combobox2 will display the similar company name on the combobox?
I am not sure if I understand your question Do you want to auto search (Auto Complete) the results from the combobox? Meaning when you press 'A', it will fetch all the combo items starting with 'A' and so on.
Mubashir Senior Engineer Storan Technologies Inc, USA Every job is a self portrait of the person who did it.
Yes,thats what I wish the combobox can auto showout all the stuff that match the user type drop down inside the combobox. Do you have any sample how should I do it? Thanks for replying.