1
我有一个文本datagridviewcolumn显示一个整数。
我将format属性设置为colTextDefaultCellStyle.Format = "#,##0";
。编辑模式下datagridview单元格的格式不同
所以显示的数字得到一个千分位。
在编辑模式下,我不想显示千位分隔符。
但我无法弄清楚如何做到这一点。例如,不起作用:
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";
}
}
的'e.FormattingApplied = TRUE;'是不是在我的情况下必要 – Gerard 2014-10-13 09:59:33
也因为e.Value是在我的情况下,值必须转换的对象'double' /转换为double的方法'的ToString (“#,## 0”)'可用 – Gerard 2014-10-13 10:02:18