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. Windows Forms
  4. except only double value in the datagridview

except only double value in the datagridview

Scheduled Pinned Locked Moved Windows Forms
tutorial
3 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.
  • K Offline
    K Offline
    kvijayajyothy
    wrote on last edited by
    #1

    i want to accept the value 123.45 but when i enter the value 123.4.5 , it accepts the value. i have set format inputmaxlength as 10 DefaultCellStyle.Format ########.## In the keypreess event i have set to accept only integer and deceimal values. so How to set to accept only in the first format i.e 123.45 and not 123.4.5 Thank you

    vijaya

    T S 2 Replies Last reply
    0
    • K kvijayajyothy

      i want to accept the value 123.45 but when i enter the value 123.4.5 , it accepts the value. i have set format inputmaxlength as 10 DefaultCellStyle.Format ########.## In the keypreess event i have set to accept only integer and deceimal values. so How to set to accept only in the first format i.e 123.45 and not 123.4.5 Thank you

      vijaya

      T Offline
      T Offline
      Tony Richards
      wrote on last edited by
      #2

      The DataGridView has a CellValidating event which is raised when a cell loses the focus. If you take a look at the MSDN documentation for it, there's a sample that shows how to validate the entry. The example looks at validating for an integer, but if you use double.TryParse instead it should do what you want.

      1 Reply Last reply
      0
      • K kvijayajyothy

        i want to accept the value 123.45 but when i enter the value 123.4.5 , it accepts the value. i have set format inputmaxlength as 10 DefaultCellStyle.Format ########.## In the keypreess event i have set to accept only integer and deceimal values. so How to set to accept only in the first format i.e 123.45 and not 123.4.5 Thank you

        vijaya

        S Offline
        S Offline
        sathish s
        wrote on last edited by
        #3

        Did you try this one?? Me.dataGridView1.Columns("xxx").DefaultCellStyle.Format = "c"

        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