如何使 datagridview 组合框加载数据库中“userid”列中列出的项目?我希望所有项目都列在“userid”列的 datagridview 组合框中。
以下是我到目前为止写的几行:
Private Sub check()
cmd = New SqlCommand("Select UserID from info", con)
da = New SqlDataAdapter(cmd)
dt = New DataTable()
da.Fill(dt)
If dt.Rows.Count > 0 Then
ComboBox1.DataSource = dt
ComboBox1.DisplayMember = "UserID"
Dim dgvcolumn As New DataGridViewComboBoxColumn
With dgvcolumn
.Width = 150
.Items.Add(ComboBox1.Items)
.DataPropertyName = "UserID"
.HeaderText = "UserID"
End With
Else
End If
End Sub