Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedValue.ToString <> "" Then ComboBox1.SelectedIndex = 0 End If End Sub Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\SHAKEE\AppData\Local\Temporary Projects\WindowsApplication1\sponsorship.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" Dim ds As New DataSet Dim adpt As New SqlDataAdapter cmd.CommandType = CommandType.Text cmd = New SqlCommand("SELECT name FROM child", con) adpt.SelectCommand = cmd cmd.Connection = con con.Open() adpt.Fill(ds, "child") con.Close() ComboBox1.DisplayMember = "countryname" ComboBox1.DataSource = ds.Tables(0).DefaultView End Sub End Class
system.data.datarowview
ComboBox1.DisplayMember = "name"
With ComboBox1 .DataSource=ds.tables(0).defaultView .DisplayMember="name" .Valuemember="name" End With
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)