设置DataGridView的属性SelectionMode为FullRowSelect
这样就使DataGridView不是选择一个字段,而是选择一整行了
设置DataGridView的属性MultiSelect为false
这样就使DataGridView不能够选择多行,只能选择一行了
string str = dataGridView1.CurrentRow.Cells[2].Value.ToString();
int intRow = dataGridView1.SelectedCells[0].RowIndex;
int intColumn = dataGridView1.SelectedCells[0].ColumnIndex;
dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Green;
DataGridView.ReadOnly属性改为True;