Results 1 to 3 of 3

Thread: Datagridview currency rounding

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2014
    Posts
    2

    Datagridview currency rounding

    I have a column in a Datagridview that I set as currency because if someone enters 2000 I want it to display as $2,000, etc. The problem is, if someone enters $8.99 it rounds it up to $9 automatically. (.net does that automatically for currency).

    Is there any way to turn off rounding?

    I want to keep the "$" and "," and the only other option I see is to set it as a text column but then if someone clicks on the column to sort it, it will not sort properly because it will be sorting as text and $10,000 would come before $4,000 in that case.

    Thanks,
    Steve

  2. #2

    Thread Starter
    New Member
    Join Date
    Aug 2014
    Posts
    2

    Re: Datagridview currency rounding

    I forgot to mention... it's an unbound datagridview...

  3. #3
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: Datagridview currency rounding

    You may perform custom sorting(numbers/currency) in the DataGridView's Sort.Compare event.
    DataGridView.SortCompare Event
    How-to-sort-a-DataGridView-Column-numerically

    KGC
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

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