ورود

View Full Version : سوال: افزودن تعداد مشخص چک باکس بع دیتاگرید



csharpdoost
دوشنبه 15 آذر 1400, 19:47 عصر
دوستان سلام.
طبق کد زیر بدون مشکل یک ستون چک باکس به دیتاگرید اضافه میشه. اما مشکل اینجاست که میخوام به تعداد مشخص مثلا n تا چک باکس اون هم از ردیف مشخص مثلا از ردیف5 این چک باکسها به ستون اضافه بشن. این کد تمام ردیف ها رو چک باکس میذاره. ممنون


//Find the Location of Header Cell.
System.Drawing.Point headerCellLocation = this.dataGridView1.GetCellDisplayRectangle(0, -1, true).Location;


//Place the Header CheckBox in the Location of the Header Cell.
headerCheckBox.Location = new System.Drawing.Point(headerCellLocation.X + 75, headerCellLocation.Y + 2);
headerCheckBox.BackColor = Color.White;
headerCheckBox.Size = new Size(18, 18);


//Assign Click event to the Header CheckBox.
headerCheckBox.Click += new EventHandler(HeaderCheckBox_Clicked);
dataGridView1.Controls.Add(headerCheckBox);



//Add a CheckBox Column to the DataGridView at the first position.
DataGridViewCheckBoxColumn checkBoxColumn = new DataGridViewCheckBoxColumn();
checkBoxColumn.HeaderText = "";
checkBoxColumn.Width = 30;
checkBoxColumn.Name = "checkBoxColumn";
dataGridView1.Columns.Insert(0, checkBoxColumn);

Mahmoud.Afrad
شنبه 20 آذر 1400, 01:11 صبح
https://social.msdn.microsoft.com/Forums/en-US/4230909c-3957-4dec-815e-eb82e67ae943/add-checkbox-to-a-specific-cell-in-data-grid-view-c

csharpdoost
شنبه 20 آذر 1400, 05:48 صبح
:تشویق:
ممنون دوست عزیز