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. TextBox

TextBox

Scheduled Pinned Locked Moved Managed C++/CLI
question
4 Posts 2 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

    Dear Sir, I need to capture only decimal number in my TextBox field on my form, how can I control that ?

    L 1 Reply Last reply
    0
    • M mikobi

      Dear Sir, I need to capture only decimal number in my TextBox field on my form, how can I control that ?

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

      void OnKeyPress(System::Windows::Forms::KeyPressEventArgs^ e)override { if((e->KeyChar=='.')) { if(this->Text->Contains(".")) e->Handled = true; } if(!(wchar_t::IsDigit(e->KeyChar) || wchar_t::IsControl(e->KeyChar))) e->Handled = true; }

      Nigah M Manzoor

      M 1 Reply Last reply
      0
      • L leonigah

        void OnKeyPress(System::Windows::Forms::KeyPressEventArgs^ e)override { if((e->KeyChar=='.')) { if(this->Text->Contains(".")) e->Handled = true; } if(!(wchar_t::IsDigit(e->KeyChar) || wchar_t::IsControl(e->KeyChar))) e->Handled = true; }

        Nigah M Manzoor

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

        Thanks for your help but the decimal point is not accepted. What to do

        M 1 Reply Last reply
        0
        • M mikobi

          Thanks for your help but the decimal point is not accepted. What to do

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

          If I do this, I obtain what I need: void OnKeyPress(System::Windows::Forms::KeyPressEventArgs^ e)override { if(!(wchar_t::IsDigit(e->KeyChar) || wchar_t::IsControl(e->KeyChar) ||(e->KeyChar=='.'))) e->Handled = true; } Thanks for you support

          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