2020年5月15日 星期五

vb.net ComboBox取得DataTable的資料 [DataTable to ComboBox]


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Table_LHH("Select * from Product")

        ComboBox1.DataSource = ds

        ComboBox1.ValueMember = "Code"

        ComboBox1.DisplayMember = "Product"

    End Sub



1
2
3
4
5
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        MsgBox(ComboBox1.SelectedValue.ToString)

    End Sub

沒有留言:

張貼留言