您可以像这样填充组合框:
comboBox1.DisplayMember = "YourColmName";
comboBox1.ValueMember = "YourFied"; //Field which you want set the value of combobox
comboBox1.DataSource = PopulateCombo(NoTypeRoom,IDBranch) // variables
在这种情况下,您的值和标签可能相同,但在其他情况下,您需要指定
Public DataTable PopulateCombo(string NoTypeRoom,string IDBranch)
{
SqlCommand cmd = new SqlCommand("viewRoom", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@NoTypeRoom", NoTypeRoom);
cmd.Parameters.AddWithValue("@IDBranch", IDBranch);
SqlDataAdapter dap = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
dap.Fill(ds);
return ds.Tables[0];
}