使用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代码帮助
答案 0 :(得分:1)
尝试设置DataGridViewComboBoxColumn的数据源属性:
// 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)