Results 1 to 4 of 4

Thread: DataGridView omits zeros

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2011
    Posts
    33

    DataGridView omits zeros

    Its normal to have the DGV ignoring zeros ?
    If the value of the string is: '23,00' in the DGV it will be showed as '23'
    but if it is '23,23' it will appear as '23,23' is that normal ?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DataGridView omits zeros

    Yes that is quite normal. After all, 23,00 is just 23. It's also 23,0 and 23,0000000 and 00023 as well. A number is just a number. If you specifically want the column to display two decimal places then you have to configure it to do so using its DefaultCellStyle.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: DataGridView omits zeros

    Actually, I see that you said:
    If the value of the string is: '23,00' in the DGV it will be showed as '23'
    If it really is a a String then that does seem a little odd. How EXACTLY is this data being retrieved and placed in the grid?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 2011
    Posts
    33

    Re: DataGridView omits zeros

    Thanks for answering,

    I wrote this
    vb Code:
    1. DGV.Columns(4).DefaultCellStyle.Format = "0.00\%"
    and I could get the '0.23' appearing but it still omits the '23.00'


    I just fill the DGV like this
    vb Code:
    1. da.Fill(ds, "products")
    2. DGV.DataSource = ds
    3. DGV.DataMember = "products"

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