آموزش اضافه کردن Combobox در DataGridView در c#.net
سلام بر تمامی برنامه نویسان ایران زمین . در این مطلب آموزشی سی شارپ ، شما یاد میگرید که چه طور یک کامبوباکس رو به یک دیتا گرید ویو اضافه کنید.
ابتدا یک پروژه جدید در ویژوال استودیو ایجاد کنید و سپس یک دیتا گرید ویو به فرمتان اضافه کنید.
برای این کار ، میتوانید از کد زیر استفاده کنید (می توانید کد را درون رویداد کلیک دکمه اضافه کنید) :
dataGridView1.ColumnCount = 3;
dataGridView1.Columns[0].Name = "Product ID";
dataGridView1.Columns[1].Name = "Product Name";
dataGridView1.Columns[2].Name = "Product Price";
string[] row = new string[] { "1", "Product 1", "1000" };
dataGridView1.Rows.Add(row);
row = new string[] { "2", "Product 2", "2000" };
dataGridView1.Rows.Add(row);
row = new string[] { "3", "Product 3", "3000" };
dataGridView1.Rows.Add(row);
row = new string[] { "4", "Product 4", "4000" };
dataGridView1.Rows.Add(row);
dataGridView1.Columns[0].Name = "Product ID";
dataGridView1.Columns[1].Name = "Product Name";
dataGridView1.Columns[2].Name = "Product Price";
string[] row = new string[] { "1", "Product 1", "1000" };
dataGridView1.Rows.Add(row);
row = new string[] { "2", "Product 2", "2000" };
dataGridView1.Rows.Add(row);
row = new string[] { "3", "Product 3", "3000" };
dataGridView1.Rows.Add(row);
row = new string[] { "4", "Product 4", "4000" };
dataGridView1.Rows.Add(row);