Imports System.Data.OleDb
Imports System.Data
Public Class Form1
Dim strconn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\test.accdb"
Dim conn As New OleDbConnection(strconn)
Dim sql As String
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
sql = ("Select car_name From car Where cate_id=1")
ComboBox1.Text = sql
End Sub
End Class
Public Class Country
Public Property Name() As String
Get
Return m_Name
End Get
Set
m_Name = Value
End Set
End Property
Private m_Name As String
Public Property Cities() As IList(Of City)
Get
Return m_Cities
End Get
Set
m_Cities = Value
End Set
End Property
Private m_Cities As IList(Of City)
Public Sub New(_name As String)
Cities = New List(Of City)()
Name = _name
End Sub
End Class
Dim countries As New List(Of Country)() From { _
New Country("USA"), _
New Country("Itly"), _
New Country("Iran"), _
New Country("UK") _
}
bindingSource1.DataSource = countries
comboBox1.DataSource = bindingSource1.DataSource
comboBox1.DisplayMember = "Name"
comboBox1.ValueMember = "Name"
Dim comboBox As New ComboBox
Dim daysOfWeek As String() = _
New String() {"Monday", "Tuesday", "Wednesday", _
"Thursday", "Friday", "Saturday", _
"Sunday"}
With comboBox
.DataSource = daysOfWeek
.Location = New System.Drawing.Point(12, 12)
.Name = "comboBox"
.Size = New System.Drawing.Size(166, 21)
.DropDownStyle = ComboBoxStyle.DropDownList
End With