J
jackson drex
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:
<pre>
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 String
Dim 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</pre>
I would like to show the similar Client company dropdown at the combobox while the user is typing the name of the company. 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?
Beside that,should I used a textbox or combobox for this event is better or any other ideas?
Hope someone can give me some help on this.
Thank you all for reading.
Regards
Jack
EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng
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:
<pre>
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 String
Dim 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</pre>
I would like to show the similar Client company dropdown at the combobox while the user is typing the name of the company. 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?
Beside that,should I used a textbox or combobox for this event is better or any other ideas?
Hope someone can give me some help on this.
Thank you all for reading.
Regards
Jack
EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng