ado.net获取datagridview中选中行的信息

来源:互联网 发布:淘宝卖家未发货骗术 编辑:程序博客网 时间:2024/05/16 17:21



 private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)        {            int row = e.RowIndex;//获取当前选中的行下标.            string id = this.dataGridView1.Rows[row].Cells[0].Value.ToString();//根据行下边获取那一行得单元格集合,取单元格中的主键内容            string value = this.dataGridView1.SelectedCells[0].Value.ToString();//选中的单元格编辑完后的值            string headName = this.dataGridView1.Columns[e.ColumnIndex].HeaderText.ToString();//选中的单元格的列的表头内容
}

原创粉丝点击