Custom format providers
See original GitHub issueI need to format data, specifically double numbers, with a custom format.
In my case, if the output is requested to be 7 digits, 3 decimals, a value of:
12.3
should be formatted as:
0012300
It is like fixed point, but with no decimal separator char.
I planned to use a custom format provider, but internally the OnFormat
methods use ToString
, which not support custom format providers (or better, ignore them when dealing with standard type such numbers).
If String.Format
was used, instead, it should work.
I am open to any suggestion which helps me to get the desired result
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to: Define and Use Custom Numeric Format Providers ...
Define a custom format provider ... Implement the IFormatProvider.GetFormat method. GetFormat is a callback method that the formatting method ( ...
Read more >Custom String Formatting in .NET
Custom format providers give you the ability to use a simple class or classes that provide custom format specifiers and options to pre-existing ......
Read more >how-to-define-and-use-custom-numeric-format-providers.md
How to: Define and Use Custom Numeric Format Providers .NET gives you extensive control over the string representation of numeric values.
Read more >Using Custom format With ToString(String, IFormatProvider)
The provider parameter defines the pattern that corresponds to the standard format specifiers, as well as the symbols and names of date and...
Read more >Custom Formatting | WinForms Controls
The Custom Formatting feature allows you to: format values that are not numeric nor date/time;; implement complex formatting of numeric or date/time values....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am pushing out a 4.4.0 release. I am going to eventually retire the
IColumnDefinition.Preprocessor
property. I have created 4 new lambda properties calledOnParsing
,OnParsed
,OnFormatting
andOnFormatted
that get called before and after parsing and formatting values.I am also adding support for setting an
IFormatProvider
on the options object to override the culture settings globally rather than needing to do it on each column individually.You’ll have to let me know whether the new delegate properties give you the flexibility you need.
It worked for me:
I believe I can easily do the reverse job while importing.
Great, many thanks!