Results 1 to 2 of 2

Thread: Formatting a number in a DataGrid column.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Posts
    30

    Formatting a number in a DataGrid column.

    Hi

    I've been searching through all the posts in this site regarding formatting a number in a datagrid column and I have found some stuff but none of it seems to work for me.

    I just need for one column in my datagrid to display as US$ currency (i.e. ###.00).

    So far, Ive seen some people say something about a NumberFormat method within the Columns collection in the datagrid, but somehow this collection is not available to me. Others say something about doing the formatting in the SQL statement with which Im getting the data from the SQLDB, but when I tried it just like they said, I get a syntax error saying FORMAT is not a valid command or function.

    Anyone know how to do this, or tell me what I may be doing wrong? Thanks!

  2. #2
    Addicted Member
    Join Date
    Nov 2000
    Location
    San Diego - California
    Posts
    251
    First you need to create a style for the datagrid.

    Go to the TableStyles property on the grid. And add a new tablestyle. Making sure the MappingName is set to the name of the table in the dataset that you want to display in this style.

    Whilst in the tablestyles dialog box , you can add column styles to the style. - See GridColumnStyles.

    Each column must be mapped to a column in the table - so if the column in the tables is called Address then the MappingName must be Address.

    And what do you see...

    Just above the mappingname property in the column dialogbox is the dreaded Format property so type #0.00 This ensures you have 2 numbers after the decimal point.

    Note: You must create columnstyles for all the column you wish to display.
    Control Data Systems
    www.members.shaw.ca/cdsystems

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width