Hello Forum,
I have to Display formatted Numbers in a Grid with the following restrictions (as Example):
here are some guilty Examples:
I already tried EditorWithMask - and in EditorSettings the DataType double / decimal - with the effect, that the decimal Numbers if empty are filled up with zeros.
Using DataType string leads to unformated Values in the cell of my UltraGrid.
Does anybody have some idea what i missed?
I tried already different combinations of
... with no effect...
Thanks for all reply'sSebastian
Hi Sebastion,
You do not need to use an EditorWithMask to get masking in the grid. The grid column already has properties for MaskInput and MaskDisplayModes built-in.
And you do not have to worry about the data type on the editor settings - the column already has a data type.
ichbinweg said:I already tried EditorWithMask - and in EditorSettings the DataType double / decimal - with the effect, that the decimal Numbers if empty are filled up with zeros.
I suspect you were on the right track here, but were just using the wrong characters in your mask if you got leading or trailing 0's. You probably need to use "n" instead of "#" or "0" in your mask.
But... I don't think there's any way to have a mask where the position of the decimal is variable. You can specify a mask like "-nnnn,nnnn" and this will allow four places before and/or after the decimal. But you can't move the decimal and put 5 digits before and 3 after, for example.
If that's what you need, then you would probably need to just leave the cell freeform with no mask and validate the data when the user leaves the cell - perhaps in the BeforeCellUpdate event.
Hi Mike,
thanks for your suggestions. I solved the length of the string in the Method keyPress of the Grid, so that the input length matches my needs.
The hints with another format Character didn't solved my problems using Datatype double.
But i couldn't solve the problem of displaying a formatted string. what i found out was that if i change in the UltraGrid columns.MaskDataMode to IncludeLiterals the string is shown as expected in the german way like for example 1.234.567,89 but if i change this property to Raw it is schown like 1234567,89.
I don't understand that way of behaviour because i set the columns.MaskDisplayMode to IncludeLiterals - why does it seem that the UltraGrid Cell takes the MaskDataMode and not the MaskDisplayMode. I already tried to set the same Properties in the EditorWithMask with no effects...
After consulting the documentation i was really sure that the editorSettings(MaskDisplayMode) overrides the columns/cell Settings - or am i wrong?
Thanks Sebastian
I solved the Rest of my problems in that way:
in my UltraGrid Code:
... ultraGrid_InitializeLayout(...)columns[i].MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals; columns[i].MaskClipMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.Raw; columns[i].MaskDataMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals;
in my EditorWithMask Code:
... CreateEditorOwnerSettings(...)// For Example: "{LOC}-n,nnn,nnn,nnn,nnn.999999"editorSettings.MaskInput = CreateMaskInput (ControlType);editorSettings.DataType = typeof(String);editorSettings.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals;editorSettings.MaskDataMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.Raw;editorSettings.MaskClipMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.Raw;// For Example: "###,###,###,###0.######;-###,###,###,###0.######"editorSettings.Format = CreateFormatString (ControlType);The object ControlType contains all information about how to set the lengths of this special control: the amount of numbers and decimal digits before and after the comma ...
anyway thanks for the Help Mike!