Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. [Solved]Show two decimal places in DataGridViewTextBoxCell [modified]

[Solved]Show two decimal places in DataGridViewTextBoxCell [modified]

Scheduled Pinned Locked Moved C#
question
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jordanwb
    wrote on last edited by
    #1

    In my DataGridView I have three columns whose ValueType is set to double so that it'll accept only numbers. Now I want it to always show 2 decimal places like "17.00" instead of "17". How do I do that?

    modified on Saturday, January 31, 2009 9:43 PM

    C N 2 Replies Last reply
    0
    • J Jordanwb

      In my DataGridView I have three columns whose ValueType is set to double so that it'll accept only numbers. Now I want it to always show 2 decimal places like "17.00" instead of "17". How do I do that?

      modified on Saturday, January 31, 2009 9:43 PM

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      By specifying a format string.

      Christian Graus Driven to the arms of OSX by Vista.

      J 1 Reply Last reply
      0
      • C Christian Graus

        By specifying a format string.

        Christian Graus Driven to the arms of OSX by Vista.

        J Offline
        J Offline
        Jordanwb
        wrote on last edited by
        #3

        And how would I do that?

        modified on Saturday, January 31, 2009 7:02 PM

        C 1 Reply Last reply
        0
        • J Jordanwb

          And how would I do that?

          modified on Saturday, January 31, 2009 7:02 PM

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          http://www.codeproject.com/KB/grid/TNumEditDataGridView.aspx?display=Print[^]

          Christian Graus Driven to the arms of OSX by Vista.

          1 Reply Last reply
          0
          • J Jordanwb

            In my DataGridView I have three columns whose ValueType is set to double so that it'll accept only numbers. Now I want it to always show 2 decimal places like "17.00" instead of "17". How do I do that?

            modified on Saturday, January 31, 2009 9:43 PM

            N Offline
            N Offline
            Najmal
            wrote on last edited by
            #5

            hi.... Just Click to know more... Cell Parsing.....

            J 1 Reply Last reply
            0
            • N Najmal

              hi.... Just Click to know more... Cell Parsing.....

              J Offline
              J Offline
              Jordanwb
              wrote on last edited by
              #6

              Okay that seems like that would work but I'm still not sure how I'd enforce 2 decimals.

              N 1 Reply Last reply
              0
              • J Jordanwb

                Okay that seems like that would work but I'm still not sure how I'd enforce 2 decimals.

                N Offline
                N Offline
                Najmal
                wrote on last edited by
                #7

                k.... Do this.... DataGridView:>>Properties:>>Edit Columns::>Appearence::>DefualtCellStyle::>Format::>FormatType::>Numeric::>Decimal Places::>2

                J 1 Reply Last reply
                0
                • N Najmal

                  k.... Do this.... DataGridView:>>Properties:>>Edit Columns::>Appearence::>DefualtCellStyle::>Format::>FormatType::>Numeric::>Decimal Places::>2

                  J Offline
                  J Offline
                  Jordanwb
                  wrote on last edited by
                  #8

                  Thanks Najmal that worked.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups