【问题标题】:Currency and decimal editor in UltragridUltragrid 中的货币和十进制编辑器
【发布时间】:2013-06-24 05:28:35
【问题描述】:

我必须为ultragrid 的单元格值格式化一些datatypes。我使用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吗?

【问题讨论】:

    标签: vb.net formatting infragistics ultrawingrid


    【解决方案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;
    

    【讨论】:

    • 在其他测试中声明和初始化的一样,好的,我将它添加到答案中
    • 不,当我尝试在我的应用程序中使用此代码时,它显示“未声明”。怎么办?
    • 我假设当在 switch 语句上方声明 editorsettings 变量时,此代码将用于您的问题的上下文中。如果不是这种情况,请自己声明。你有代码。
    • 有什么可以帮助您的吗?您会看到使用变量的代码。您应该声明它,然后才能使用该变量。如果编译器拒绝接受代码,那是因为变量没有声明,或者它的声明在你使用它的地方不可见,就像那样。用你的真实代码更新问题
    • 请在这个问题上提供帮助stackoverflow.com/questions/17312414/…
    【解决方案2】:

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

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 2015-02-02
      • 2016-01-24
      • 1970-01-01
      相关资源
      最近更新 更多