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. Number only text box

Number only text box

Scheduled Pinned Locked Moved C#
csharpc++question
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.
  • O Offline
    O Offline
    Ollie
    wrote on last edited by
    #1

    Hi, How do you make a text box on a windows form accept numbers only? These is really easy in VC++ 6.0, can't be hard in C# Cheers Ollie Riches:confused:

    R M O 3 Replies Last reply
    0
    • O Ollie

      Hi, How do you make a text box on a windows form accept numbers only? These is really easy in VC++ 6.0, can't be hard in C# Cheers Ollie Riches:confused:

      R Offline
      R Offline
      Rupel
      wrote on last edited by
      #2

      there's already a thread about that problem in this forum (currently on the next page) :wq

      1 Reply Last reply
      0
      • O Ollie

        Hi, How do you make a text box on a windows form accept numbers only? These is really easy in VC++ 6.0, can't be hard in C# Cheers Ollie Riches:confused:

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

        I know two way for it. One: http://www.codeproject.com/cs/miscctrl/maskedcsedit.asp Two: Handle KeyPress event of text box yourself:

        private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
        if(e.KeyChar < 48 || e.KeyChar > 57 )
        e.Handled = true;
        }

        Mazy "The path you tread is narrow and the drop is shear and very high, The ravens all are watching from a vantage point near by, Apprehension creeping like a choo-train uo your spine, Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd

        1 Reply Last reply
        0
        • O Ollie

          Hi, How do you make a text box on a windows form accept numbers only? These is really easy in VC++ 6.0, can't be hard in C# Cheers Ollie Riches:confused:

          O Offline
          O Offline
          Ollie
          wrote on last edited by
          #4

          The Answer is... http://www.codeproject.com/script/comments/forums.asp?forumid=1649&select=160478&fr=51#xx159561xx

          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