Ultragrid中的货币和十进制编辑器

时间:2013-06-24 05:28:35

标签: vb.net formatting infragistics ultragrid

我必须为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;
       }
   }
}

现在,如何设置currencydecimal值的格式?

是否有currencyeditordecimaleditor

2 个答案:

答案 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”

由于