我有一个DataGridView
我的代码:
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex].Name == BaoDuong.DVThucHien)
{
e.Value = "BTWASECO";
e.FormattingApplied = true;
}
}
////单击单击
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show(dataGridView1.CurrentRow.Cells[e.ColumnIndex].Value.ToString());
}
我想获得价值" BTWASECO",但结果是:http://upanhtocdo.com/image.php?di=IM76
答案 0 :(得分:1)
dataGridView1.CurrentRow.Cells[e.ColumnIndex].Value
尚未更改
尝试使用FormattedValue
MessageBox.Show(dataGridView1.CurrentRow.Cells[e.ColumnIndex].FormattedValue.ToString());