10-07-19, 06:01 PM
(آخر تعديل لهذه المشاركة : 10-07-19, 06:31 PM {2} بواسطة asemshahen5.)
خود دا الكود و افهمه و عدله حسب ما تراه :
PHP كود :
// ------------------[تعبئة كمبو بوكس اللي في الغريد فيو]-------------------
public static void FillDGVComBobx(DataGridView dgv, string Sql, string displayCol)
{
SqlDataAdapter sda1 = new SqlDataAdapter(Sql, Con);
DataTable dt1 = new DataTable();
sda1.Fill(dt1);
ArrayList StringList = new ArrayList();
foreach (DataRow item in dt1.Rows)
{
StringList.Add(item[displayCol].ToString());
}
foreach (DataRow item in dt1.Rows)
{
int n = dgv.Rows.Add();
var CellSample = new DataGridViewComboBoxCell();
CellSample.DataSource = StringList;
dgv.Rows[n].Cells[0] = CellSample;//Name,EmployeeID
dgv.Rows[n].Cells[1].Value = item["EmployeeID"].ToString();
dgv.Rows[n].Cells[2].Value = item["Name"].ToString();
dgv.Rows[n].Cells[0].Value = StringList[n].ToString();
}
}
PHP كود :
DB.FillDGVComBobx(dataGridView1, "select Office,Name,EmployeeID from Employee", "Office");
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
