' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Drawing
Imports System.Windows.Forms

Namespace DefaultNamespace
    Public Class MainForm
    Inherits Form
        Private comboBox1 As ComboBox

        Public Sub New()
            InitializeComponent
        End Sub

        <STAThread()> _
        Public Shared Sub Main(ByVal args As String())
            Application.Run(New MainForm)
        End Sub

        Private Sub InitializeComponent()
            comboBox1 = New ComboBox
            SuspendLayout
            comboBox1.Location = New Point(50, 50)
            comboBox1.Size = New Size(150, 25)
            Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Databases\MSAccess\Test.mdb")
            con.Open
            Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM T1", con)
            Dim ds As DataSet = New DataSet
            da.Fill(ds, "T1")
            comboBox1.DataSource = ds.Tables("T1")
            comboBox1.DisplayMember = "F2"
            comboBox1.ValueMember = "F1"
            ClientSize = New Size(250, 400)
            Controls.Add(comboBox1)
            Text = "Combobox test"
            ResumeLayout(False)
        End Sub
    End Class 
End Namespace
