我尝试在Datagridview中为DataGridViewButtonColumn
单元格设置值。
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dgv.Columns[e.ColumnIndex].Name.Equals("id")) {
e.Value = 14;
}
}
然后我尝试在点击事件后获得价值:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.CurrentCell.ColumnIndex.Equals(1) && e.RowIndex != -1)
{
// GET HERE
}
}
那么,如何在事件e.Value = 14
中获得价值dataGridView1_CellClick
?
答案 0 :(得分:1)
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
var dg = (DataGridView)sender;
dg[e.ColumnIndex, e.RowIndex].Value = 123;
}