111,126
社区成员
发帖
与我相关
我的任务
分享
// 单击 DataGridView 单元格时 获取DataGridView行的索引
int Index = DataGridViewName.Rows[DataGridViewName.SelectedCells[0].RowIndex].Cells[0].RowIndex;
根据行的索引把里面单元格的所有的值都取出来。。。传递给另外的窗体就可以了,至于怎么传递,方法很多…
DataGridViewRow currentrow=dataGridView.CurrentRow;
if(currentrow!=null)
{
String str=currentrow.Cells["字段名"].Value.ToString();
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
//你点击那一行的第一列值
string strId = dataGridView1[1, e.RowIndex].Value.ToString().Trim();
}
}