我正在尝试这样的事情:
DataGridViewComboBoxColumn Column2 =new DataGridViewComboBoxColumn();// Column2 is my datagridview's combobox
SqlCommand command = new SqlCommand("select name from inventorymaster", con);
con.Open();
SqlDataReader read = command.ExecuteReader();
while (read.Read())
{
Column2 = (read["name"].ToString());
}
read.Close();
我收到错误:
无法将类型'string'隐式转换为'System.Windows.Forms.DataGridViewComboBoxColumn'
答案 0 :(得分:0)
SqlCommand sqlCmd = new SqlCommand("SELECT name FROM Inventorymaster", con);
con.Open();
SqlDataReader sqlReader = sqlCmd.ExecuteReader();
while (sqlReader.Read())
{
Column1.Items.Add(sqlReader["name"].ToString());
}
sqlReader.Close();