我必须为datatypes
的单元格值格式化一些ultragrid
。我使用DateTimeEditor
格式化datetime
值。
//代码
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
{
if (e.ReInitialize == false)
{
DefaultEditorOwnerSettings editorSettings;
DateTimeEditor datetime_editor;
string condition = e.Row.GetCellValue("Condition").ToString();
switch (condition)
{
case "TEST1":
editorSettings = new DefaultEditorOwnerSettings()
editorSettings.DataType = typeof(DateTime);
editorSettings.MaskInput = "mm/dd/yyyy";
datetime_editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings));
e.Row.Cells["DateInfo"].Editor = datetime_editor;
break;
case "TEST2":
editorSettings = new DefaultEditorOwnerSettings()
editorSettings.DataType = typeof(DateTime);
editorSettings.MaskInput = "hh:mm:ss";
datetime_editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings));
e.Row.Cells["DateInfo"].Editor = datetime_editor;
break;
}
}
}
现在,如何设置currency
和decimal
值的格式?
是否有currencyeditor
或decimaleditor
?
答案 0 :(得分:1)
您可以使用EditorWithMask,但请记住,列具有数据类型,如果您的列数据类型与预期的Editor数据类型不兼容,则结果是不可预测的
EditorWithMask currency_editor;
DefaultEditorOwnerSettings editorSettings = new DefaultEditorOwnerSettings();
editorSettings.DataType = typeof(decimal);
currency_editor = new EditorWithMask(new DefaultEditorOwner(editorSettings));
editorSettings.MaskInput = "€ nnn.nn";
e.Row.Cells["decimal_column_name"].Editor = mask_editor;
答案 1 :(得分:-3)
试试这个编码 currencyColumn.Format =“##,###,####。00”
由于