DataGridView选中某个单元格中时自动选中当前行

   当用户单击某个单元格时,自动选中当前行。

  

1         //单击某个单元格时,自动选中一行.
2         private void dataGridView1_Click(object sender, EventArgs e)
3         {
4             if (this.dataGridView1.CurrentCell == null) //[BugHere][MustAdd]
5             {
6                 return;
7             }
8             this.dataGridView1.Rows[this.dataGridView1.CurrentCell.RowIndex].Selected = true;
9         }
posted @ 2012-09-03 13:00  C#老头子  Views(782)  Comments(0Edit  收藏  举报