我查找了 .ValueMember 并发现它只能接受我假设的整数。我的问题是,如果我的联赛列返回 ABC,它可以同时是显示名称和组合框的值吗?如果有任何帮助来实现这一点,我们将不胜感激。
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim con As New MySqlConnection("Server=xxx.xxx.xxx.xxx.;Database=database;Uid=username;Pwd=password;")
Dim da As New MySqlDataAdapter("SELECT league FROM league_names ORDER BY league ASC", con)
Dim dt As New DataTable
da.Fill(dt)
'Display table data in combobox
ComboBox1.DisplayMember = "league"
ComboBox1.ValueMember = "league"
ComboBox1.DataSource = dt
End Sub