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. Managed C++/CLI
  4. DataGridView Cell Format

DataGridView Cell Format

Scheduled Pinned Locked Moved Managed C++/CLI
c++question
5 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.
  • M Offline
    M Offline
    mikobi
    wrote on last edited by
    #1

    I use Visual c++ Net 2005 I have in my DataGridView one Column 'quantite'. In this column I need to put only numbers. How can I format this column sothat I can only capture numbers ?

    T 1 Reply Last reply
    0
    • M mikobi

      I use Visual c++ Net 2005 I have in my DataGridView one Column 'quantite'. In this column I need to put only numbers. How can I format this column sothat I can only capture numbers ?

      T Offline
      T Offline
      teejayem
      wrote on last edited by
      #2

      This kinda goes along with my answer to your previous question.[^]. There is no "DataGridViewMaskedTextBoxCell" available so you will need to get the cell that the user just modified and format/validate the value yourself.

      Don't be overcome by evil, but overcome evil with good

      L 1 Reply Last reply
      0
      • T teejayem

        This kinda goes along with my answer to your previous question.[^]. There is no "DataGridViewMaskedTextBoxCell" available so you will need to get the cell that the user just modified and format/validate the value yourself.

        Don't be overcome by evil, but overcome evil with good

        L Offline
        L Offline
        leonigah
        wrote on last edited by
        #3

        System::Void grid_CellValidating(System::Object^ sender, System::Windows::Forms::DataGridViewCellValidatingEventArgs^ e) { bool bInt = false; for each (wchar_t ch in e->FormattedValue->ToString()->Trim()) if(!wchar_t::IsDigit(ch)) bInt = true; if(e-->ColumnIndex==2)//Quantity { if(bInt) ;//DO else return; } }

        Nigah M Manzoor

        L 1 Reply Last reply
        0
        • L leonigah

          System::Void grid_CellValidating(System::Object^ sender, System::Windows::Forms::DataGridViewCellValidatingEventArgs^ e) { bool bInt = false; for each (wchar_t ch in e->FormattedValue->ToString()->Trim()) if(!wchar_t::IsDigit(ch)) bInt = true; if(e-->ColumnIndex==2)//Quantity { if(bInt) ;//DO else return; } }

          Nigah M Manzoor

          L Offline
          L Offline
          leonigah
          wrote on last edited by
          #4

          for float type variable : bool bFloat = false; int i = 0; for each (wchar_t ch in e->FormattedValue->ToString()->Trim()) { if(!wchar_t::IsDigit(ch)) { if(ch=='.' && i == 0) { bFloat = false; i++; } else bFloat = true; } }

          Nigah M Manzoor

          M 1 Reply Last reply
          0
          • L leonigah

            for float type variable : bool bFloat = false; int i = 0; for each (wchar_t ch in e->FormattedValue->ToString()->Trim()) { if(!wchar_t::IsDigit(ch)) { if(ch=='.' && i == 0) { bFloat = false; i++; } else bFloat = true; } }

            Nigah M Manzoor

            M Offline
            M Offline
            mikobi
            wrote on last edited by
            #5

            Thanks Nigah

            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