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. Int textBox

Int textBox

Scheduled Pinned Locked Moved C#
javascripttutorial
3 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.
  • B Offline
    B Offline
    blink4me
    wrote on last edited by
    #1

    Hi, I finally figured how to parse my string as singles but I am looking for a way to prevent the user from entering non numeric values in the textBox, could a maskEdit do this or is there a way to do it directly with the textBox. Thanks Jean S. Paquet // JS Paquet cout << "Thank you all" << endl;

    A 1 Reply Last reply
    0
    • B blink4me

      Hi, I finally figured how to parse my string as singles but I am looking for a way to prevent the user from entering non numeric values in the textBox, could a maskEdit do this or is there a way to do it directly with the textBox. Thanks Jean S. Paquet // JS Paquet cout << "Thank you all" << endl;

      A Offline
      A Offline
      Andreas Philipson
      wrote on last edited by
      #2

      Just handle the KeyPress event of the textbox check each character... textBox1.KeyPress += new new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);

      private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
      {
         if (!Char.IsDigit (e.KeyChar))
         {
            e.Handled = true;
         }
      }
      

      Andreas Philipson

      B 1 Reply Last reply
      0
      • A Andreas Philipson

        Just handle the KeyPress event of the textbox check each character... textBox1.KeyPress += new new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);

        private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
           if (!Char.IsDigit (e.KeyChar))
           {
              e.Handled = true;
           }
        }
        

        Andreas Philipson

        B Offline
        B Offline
        blink4me
        wrote on last edited by
        #3

        and how do I handle multiple verification, I want to allow control (BKSPACE, etc.) and dots. // JS Paquet cout << "Thank you all" << endl;

        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