سلام با این کد میتونی اینکارو انجام بدی البت من از دیتا
گرید استفاده میکنم
من خودم از این روش استفاده کردم که تو همین سایت بچه ها راهنماییم کردن فقط یه مشکل کویک داره ببین برا شمام این مشکل پیش میاد؟؟
privatevoid dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0)
{
if (dataGridView1.Rows[rowindex].Cells[0].Value != null)
{
DataGridViewComboBoxCell Cell_model = new DataGridViewComboBoxCell();
bind_model(Convert.ToString(dataGridView1[0,e.RowIndex].Value), ref Cell_model);
((DataGridViewComboBoxCell)dataGridView1.Rows[e.RowIndex].Cells[1]).DataSource = Cell_model.Items;
}
}
publicvoid bind_model(String str, ref DataGridViewComboBoxCell Cell_Unit)
{
// source(" select unit from tbl_articles where name ='" + _Article_Name + "'");
// str = dataGridView1.Rows[rowindex].Cells[0].Value.ToString();
objda.SelectCommand.CommandText = "select model from goods where type like '" + str + "'";
objds = new DataSet();
objds.Clear();
objda.Fill(objds, "goods");
Cell_Unit.Items.Clear();
for (int i = 0; i < objds.Tables["goods"].Rows.Count; i++)
{
Cell_Unit.Items.Add(objds.Tables["goods"].Rows[i]["model"].ToString());
}
}