//ComboBox控件拖放到DataGridView控件的某个位置
//添加年龄下拉框
private void BindAge()
{
//我这里添加的是静态数据,一般都是从数据库读出来的,这里就不介绍了
DataTable dt=new DataTable;
dt.Columns.Add("Value");
dt.Columns.Add("Name");
DataRow dr;
dr = dt.NewRow();
dr[0] = "0";
dr[1] = "10years old";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = "1";
dr[1] = "12years old";
dt.Rows.Add(dr);
//cmb为ComboBox控件的名称
cmb.ValueMember = "Value";
cmb.DisplayMember = "Name";
cmb.DataSource = dt;
cmb.DropDownStyle = ComboBoxStyle.DropDownList;
}
//在主窗体调用函数
private void MainForm_Load(object serder,EventArgs e)
{
BindAge();
}