2009-11-23 91 views
1

使用VB.NET如何在下拉列表

我想在Datagridviewcombobox列

代碼添加數據的添加項目。

cmd = New SqlCommand("SELECT Sched_Name from tb_Sched_Master", con) 
    ada = New SqlDataAdapter(cmd) 
    ada.Fill(ds1) 
    x.HeaderText = "Select Employee" 
    DataGrid4.Columns.Add(x) 
    x.Items.Add(ds1.Tables(0)) 

但我無法獲取數據,我的代碼有什麼問題。

需要vb.net代碼幫助

回答

1

嘗試設置你的DataGridViewComboBoxColumn的DataSource屬性:

// Column that will be used to set the value of the items in your combobox : 
yourColumn.ValueMember = "YourValueField" 

// Column that will be displayed for items in your combobox : 
yourColumn.DisplayMember = "YourTextField" 

yourColumn.DataSource = ds1.Tables(0) 
+0

你說的你的價值領域,提起文字的意思是,你能不能請。 – Gopal 2009-11-23 13:01:08