[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

(Brian Quinlan)

1/21/2003 5:41:00 PM

Hi,

I didn't really know where this question belongs so I may have posted it to
some
inappropriate groups. Sorry about that.

I was wondering if it is possible to implement an IFormatProvider (or
related
interface) and do my own .ToString() conversions. The reason that this would
be
handy for me is that I want to display numbers using a certain number of
significant
figures. For example, if the number of significant figures is 3:

123456 => 123000
12345.6 => 12300
1234.56 => 1230
123.456 => 123
12.3456 => 12.3
1.23456 => 1.23
0.123456 => 0.123

AFAIK, this formatting is not expressable by modifying the properties of a
NumberFormatInfo.

I could, of course, write my own string conversion function outside of
the IFormatProvider interface but how would I use it with .NET controls
that require an IFormatProvider e.g. DataGrid?

Cheers,
Brian