Results 1 to 3 of 3

Thread: [RESOLVED] format of cell in datagridview to 2 dp

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2011
    Posts
    178

    Resolved [RESOLVED] format of cell in datagridview to 2 dp

    hi everyone,
    i am just having a weird issue setting the cell of a datagrid to two decimal places. I have set at design time the cell format to N2. see attached snapshot. but it is still not working.
    can anyone advise me here?
    thanks
    Attached Images Attached Images  

  2. #2
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: format of cell in datagridview to 2 dp

    Hi,

    You have to set the ValueType of the column to use numeric formatting. From what I can see there is no way to set this property in the IDE so you need to do this in code, in let's say, the Form.Load event. i.e:-

    Code:
    DataGridView1.Columns("YourColumn").ValueType = GetType(System.Decimal)
    Hope that helps.

    Cheers,

    Ian

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2011
    Posts
    178

    Re: format of cell in datagridview to 2 dp

    works like a charm.
    thanks a bunch ian.
    appreciate it.

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