Standard formatting Vs Custom formatting in Ultrag

2019-03-01 12:35发布

I'm trying to format a Ultragridcell using the following code and it works fine.

//Code

            DefaultEditorOwnerSettings editorSettings;
            DateTimeEditor datetime_editor;
            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;

But when I try to format like the below code, it fails.

//Code

            DefaultEditorOwnerSettings editorSettings;
            DateTimeEditor datetime_editor;
            editorSettings = new DefaultEditorOwnerSettings()
            editorSettings.DataType = typeof(DateTime);
            editorSettings.MaskInput = "D";
            datetime_editor = new DateTimeEditor(new DefaultEditorOwner(editorSettings));
            e.Row.Cells["DateInfo"].Editor = datetime_editor;

Is that only the custom formatting that too only limited types works with the cell or i'm wrong somewhere.

Need an advice on this.

1条回答
Animai°情兽
2楼-- · 2019-03-01 13:14

It seems that you think that MaskInput property supports all the formatting functionality provided by Composite Formatting, but I don't think that it is true.
The formatting available for MaskInput as far as I know are limited to only these provided by the UltraGrid Designer.

Using the UltraGrid Designer (right click on the UltraGrid control, select UltraGrid Designer) click on the Data Schema and define a data schema in which one of the columns will be a DateTime column. Then go to the Bands and Column Settings node, select columns and then the column defined as DateTime. In the properties window you can find the MaskInput property and its allowed values. You could try to experiment with the predefined masks and check if there is one that fits your requirements.

As I have said this is what I suppose to be true. I don't know if there is another advanced mode to set these properties at design time or at Runtime. If, someone from Infragistics, wants to add something to this answer would be welcome

查看更多
登录 后发表回答