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. Datagrid view

Datagrid view

Scheduled Pinned Locked Moved C#
help
4 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.
  • H Offline
    H Offline
    hiremath71
    wrote on last edited by
    #1

    hi, i am using datagridview and i am having 4 columns now i want to validate the entry like e.g i should enter numbers in 2'nd column ,text in thied column pls help me. with regards prasad:)

    D R 2 Replies Last reply
    0
    • H hiremath71

      hi, i am using datagridview and i am having 4 columns now i want to validate the entry like e.g i should enter numbers in 2'nd column ,text in thied column pls help me. with regards prasad:)

      D Offline
      D Offline
      dsl fahk
      wrote on last edited by
      #2

      I think you mean that make sure that what was entered in each column is in the correct format, which you can do with regular expressions. There are a lot of articles about it, try RegexTester.asp[^] to get you started. Hope this helps. :)

      1 Reply Last reply
      0
      • H hiremath71

        hi, i am using datagridview and i am having 4 columns now i want to validate the entry like e.g i should enter numbers in 2'nd column ,text in thied column pls help me. with regards prasad:)

        R Offline
        R Offline
        Rocky
        wrote on last edited by
        #3

        well u can handle this situation without using regular expressions as well. You need to handle the cellValidating event of the DGV and in that u'd code somthin like this. int i; if(e.ColumnIndex == myDGVCol1.DisplayIndex) { if(!Int32.TryParse(e.FormattedValue,out i)) { e.Cancel = true; MessageBox.Show("It is not an integer"); // or myDGV[e.ColumnIndex, e.RowIndex].ErrorText ="Whatever"; } // similarly u can use the tryparse methods of DateTime classes etc } and in order to go without taking special charaters u can use string manuipulation but I dont have the sample right now... hope it helps Rocky

        H 1 Reply Last reply
        0
        • R Rocky

          well u can handle this situation without using regular expressions as well. You need to handle the cellValidating event of the DGV and in that u'd code somthin like this. int i; if(e.ColumnIndex == myDGVCol1.DisplayIndex) { if(!Int32.TryParse(e.FormattedValue,out i)) { e.Cancel = true; MessageBox.Show("It is not an integer"); // or myDGV[e.ColumnIndex, e.RowIndex].ErrorText ="Whatever"; } // similarly u can use the tryparse methods of DateTime classes etc } and in order to go without taking special charaters u can use string manuipulation but I dont have the sample right now... hope it helps Rocky

          H Offline
          H Offline
          hiremath71
          wrote on last edited by
          #4

          Thank u it is working with regards prasad

          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