0

I have to format some of the datatypes for cell values of an ultragrid. I have used the DateTimeEditor for formatting the datetime values.

//Code

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;
       }
   }
}

Now, How can I format the currency and decimal values?

Is there any currencyeditor or decimaleditor?

4

2 回答 2

1

您可以使用 EditorWithMask,但请记住,列具有数据类型,如果您的列数据类型与预期的编辑器数据类型不兼容,则结果是不可预测的

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;
于 2013-06-24T09:06:35.580 回答
-3

试试这个编码 currencyColumn.Format = "##,###,####.00"

谢谢

于 2013-06-24T05:41:24.640 回答