All, I used the below code add a select all check box into DataGridView. So far it works fine. But still have a problem with tab index order. please review it.
for (int i = 0; i < 3; i++)
{
dataGridView1.Rows.Add();
DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[i];
row.Cells[0].Value = true;
row.Cells[1].Value = "cell";
row.Cells[2].Value = "cell";
}
Rectangle rect =
this.dataGridView1.GetCellDisplayRectangle(0, -1, true);
checkBox1.Location = rect.Location;
checkBox1.Left = 9;
checkBox1.Top = 3;
dataGridView1.Controls.Add(checkBox1);
My desired tab order setting in the design time is shown below.
But in the run-time .The tab order is weird. The checkbox tab order is always behind all the cells of the DataGridView. And If the checkbox is not contained in the grid. the order would be fine. it will follow the design order. Is there any way to fix it ? thanks.
I think order is broken by moving checkBox1 into dataGridView controls collection. You should then handle tabs within that control. It could be done by creating custom DataGridView and overriding ProcessTabKey method See
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.