最近由于程序需要,需要实现指定的行为datagridview的currentrow ,当我设置 dataGridView1.Rows[i].Selected = true时,刷新后,界面显示是当前行被选中,但是后来发现它的currentrow变成 默认的第一行,后来找到下面方法实现了此功能  

 for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    if (dataGridView1.Rows[i].Cells["code"].Value.ToString()== tcAppointment.SelectedTab.Tag.ToString())

                    {
                        dataGridView1.Rows[i].Selected = true;
                        this.dataGridView1.CurrentCell = this.dataGridView1.Rows[i].Cells[0];
                    }
                }

 

来源:http://hi.baidu.com/brotherzhuo/item/bb970a0e743dbccf2e4c6bcd

相关文章:

  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2021-10-19
猜你喜欢
  • 2022-01-07
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
相关资源
相似解决方案