質問

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?

役に立ちましたか?

解決

You could use a EditorWithMask, but keep in mind that a column has a datatype and if your column datatype is not compatible with the expected Editor datatype the results are unpredictable

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;

他のヒント

Try this coding currencyColumn.Format = "##,###,####.00"

Thanks

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top