https://blog.csdn.net/weixin_34198881/article/details/93301519

 

//定位到指定行(样式)
dataGridView1.ClearSelection();
dataGridView1.Rows[selectIndex].Selected = true;

//让指定行处于选中状态(状态)
dataGridView1.CurrentCell = dataGridView1.Rows[selectIndex].Cells[1];
dataGridView1.CurrentRow.Selected = true;

当时使用的场景:处理行数据上移下移的情况下用的。

注:这四句需要放在dataGridView1.Refresh()的后面才会起作用,前面两句会定位到指定的行,后面两句会使定位到的指定行处于选中状态,若不使用后面的两句,而使用dataGridView1.CurrentRow.Index得到的index将会一直是0(第一行)

转载于:https://www.cnblogs.com/sugarwxx/p/9354421.html

 

foreach (DataGridViewRow dgvr in dataGridView2.Rows){
  this.dataGridView1.CurrentCell = dgvr.Cells["上传进度"];
this.dataGridView2.Refresh();
}

 

 

//定位到指定行(样式)
dataGridView1.ClearSelection();
dataGridView1.Rows[selectIndex].Selected = true;

//让指定行处于选中状态(状态)
dataGridView1.CurrentCell = dataGridView1.Rows[selectIndex].Cells[1];
dataGridView1.CurrentRow.Selected = true;

当时使用的场景:处理行数据上移下移的情况下用的。

注:这四句需要放在dataGridView1.Refresh()的后面才会起作用,前面两句会定位到指定的行,后面两句会使定位到的指定行处于选中状态,若不使用后面的两句,而使用dataGridView1.CurrentRow.Index得到的index将会一直是0(第一行)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2022-02-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案