我有一个显示整数的文本数据网格视图列。
我将格式属性设置为colTextDefaultCellStyle.Format = "#,##0";
.
所以显示的数字有千位分隔符。
在编辑模式下,我不想显示千位分隔符。
但我不知道该怎么做。这例如不起作用:
void dgv_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
DataGridViewCell cell = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (e.ColumnIndex == colText.Index)
{
if (cell.IsInEditMode) cell.Style.Format = "";
else cell.Style.Format = "#,##0";
}
}