josephkim
2 years ago
Hello,

I been trying to make use of the FormatProvider feature, but it simply doesn't work on my project, even when I referenced the OutlookView sample project.

The code is straightforward,

iGrid1.Cols["Time"].CellStyle.FormatProvider = new CustomDateFormatProvider();

And I add my rows accordingly and it still shows the raw value instead of the formatted value that I expected.

But it doesn't even trigger the format code. Even when I add a breakpoint, it doesn't enter.



What exactly do I need to get it working?

Thanks!
Igor/10Tec
2 years ago
A custom FormatProvider works together with the FormatString property. Here is an example from the documentation (see the Cell Format Providers topic):

//specify own "ip" format
iGrid1.Cols[0].CellStyle.FormatString = "{0:ip}";
//set the format provider for the IP Address column
iGrid1.Cols[0].CellStyle.FormatProvider = new IPFormatProvider();

In the case of the Outlook sample, the FormatString property is set at design time:

this.fCellStyleReceived.FormatString = "{0}";

So that, I think, the following statement should solve your problem:

iGrid1.Cols["Time"].CellStyle.FormatString = "{0}";