当我在 datagridview 上保存新项目时,该语句
MessageBox.Show(this.tb_aprovacao_admissaoDataGridView.CurrentRow.Cells[0].Value.ToString());
显示值 -1。我怎样才能改变它以显示真实的身份证号码?
谢谢大家。
当我在 datagridview 上保存新项目时,该语句
MessageBox.Show(this.tb_aprovacao_admissaoDataGridView.CurrentRow.Cells[0].Value.ToString());
显示值 -1。我怎样才能改变它以显示真实的身份证号码?
谢谢大家。
Depends how you want to get the value.. Do you want to get the value after you click on the cell, or on the click of a button or?
If you want to do it on the cell click event, you can do it like this:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
{
MessageBox.Show(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
}
}
To get it with a button:
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(dataGridView1.CurrentCell.Value.ToString());
}