Re: Another modifier for the datagridview column.Format() property?

Tech-Archive recommends: Speed Up your PC by fixing your registry



Earl,

You're on the right track. In your format, you can specifiy an N length for
numeric formats.

{0:Cn} Currency. Displays numeric values in currency format with a leading
dollar sign; n indicates the number of decimal places. If n is omitted, the
default currency precision is two decimal digits.
{0:Dn} Decimal. Displays integer values; n indicates the minimum number of
digits desired in the resulting string. If necessary, the number is padded
with zeros to its left to produce the number of digits given by the
precision specifier.
{0:Fn} Fixed-point. Displays numeric values in fixed format; n indicates the
desired number of decimal places.
{0:Nn} Number. The number is converted to a string; n indicates the desired
number of decimal places. Commas are inserted between each group of three
digits to the left of the decimal point.
{0:Pn} Percent. Displays numeric values in percentage format; n indicates
the desired number of decimal places.
(from
http://msconline.maconstate.edu/Tutorials/ASPNET2/ASPNET07/aspnet07-01.aspx)

You can then specify this programatically, using:

dgv.Columns(0).DefaultCellStyle.Format = "D3"

Hope this helps,


Steve


"Earl" <brikshoe@xxxxxxxxxxxxxxxxx> wrote in message
news:ujyKYJdpHHA.3320@xxxxxxxxxxxxxxxxxxxxxxx
Somewhat of a trivial thing, but I have not seen this either on Google or
in the documentation: Is it possible to apply another modifier to the
Format property of a datagridview column?

I've got some expression columns that calculate decimal values which may
end up like "4.333333333". I'd like to round that down to 3 decimal
places, but you cannot use Round in your expression columns.
(Incidentally, I'm not interested in adding two more columns to the data
coming across with the SQL just in order to round it -- I'd rather keep
the expression columns.)

If you manually add columns to a dgv, you can set the number of decimal
places, so it would seem that there is a property available to do this
programmatically.

Does anyone know if there another modifier? Perhaps something like
dgv.Columns(0).DefaultCellStyle.Format = "d, 3" (which does not have any
affect)?



.



Relevant Pages

  • Re: Format Problem
    ... I set the numberformat property to General and it still does ... for the long date format. ... for the month and date separator, and displays two digits for the year. ... Currency Displays a number according to the Windows regional ...
    (microsoft.public.excel.programming)
  • Re: Another modifier for the datagridview column.Format() property?
    ... you can specifiy an N length ... Displays numeric values in currency format with a leading ... the default currency precision is two decimal digits. ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: Regional settings modification
    ... Country Text Indexed ... This application is intended for different countries and differend currency ... They are still derived from the regional settings. ... simply copied the pound symbol and used it in the format property for text ...
    (microsoft.public.access.modulesdaovba)
  • RE: Format Problem
    ... for the long date format. ... Medium date Displays a date according to the Windows regional setting ... for the month and date separator, and displays two digits for the year. ... Currency Displays a number according to the Windows regional setting ...
    (microsoft.public.excel.programming)
  • Re: Currency conversion
    ... I agree that the way Access works with regard to currency ... format at all with a currency field, ... again it displays per regional settings. ...
    (microsoft.public.access.modulesdaovba)