1、获得某个(指定的)单元格的值:
dataGridView1.Rows[i].Cells[j].Value;
2、获得选中的总行数:
dataGridView1.SelectedRows.Count;
3、获得当前选中行的索引:
dataGridView1.CurrentRow.Index;
4、获得当前选中单元格的值:
dataGridView1.CurrentCell.Value;
5、取选中行的数据
string[] str = new string[dataGridView.Rows.Count];
for(int i;i<dataGridView1.Rows.Count;i++)
if(dataGridView1.Rows[i].Selected == true)
str[i] = dataGridView1.Rows[i].Cells[1].Value.ToString();
7、获取选中行的某个数据
int a = dataGridView1.SelectedRows.Index;
dataGridView1.Rows[a].Cells[“你想要的某一列的索引,想要几就写几”].Value;
8、选中当前行的某个单元格的值
一:
selectedRows[0].cell[列索引].values
//其中row0即当前选中的行
二:
int a=dataGridView1.CurrentRow.Index;
string str=dataGridView1.Row[a].Cells[“strName”].Value.Tostring();
9、取当前选择的单元格内容
DataGridView1.SelectedCells(0).Value.ToString
10、选择当前单元格第N列内容
DataGridView1.Rows(e.RowIndex).Cells(2).Value.ToString