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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Textbox

Textbox

Scheduled Pinned Locked Moved C#
question
4 Posts 4 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.
  • P Offline
    P Offline
    PaulaM
    wrote on last edited by
    #1

    My application has a textbox,how can i make my textbox enter numeric velues only :) thanks regards paula

    S G C 3 Replies Last reply
    0
    • P PaulaM

      My application has a textbox,how can i make my textbox enter numeric velues only :) thanks regards paula

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Did you try overriding the ProcessCmdKey[^] method? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      1 Reply Last reply
      0
      • P PaulaM

        My application has a textbox,how can i make my textbox enter numeric velues only :) thanks regards paula

        G Offline
        G Offline
        Gulfraz Khan
        wrote on last edited by
        #3

        Did you try the google?

        1 Reply Last reply
        0
        • P PaulaM

          My application has a textbox,how can i make my textbox enter numeric velues only :) thanks regards paula

          C Offline
          C Offline
          Craig G Fraser
          wrote on last edited by
          #4

          A Simple way is to use the textbox's KeyPress Event. Check for the key pressed and if it is not a valid key then cancel the event (e.cancel) which will cause the key value not to be displayed. The code below is an example of the KeyPress event for a textbox that only allows Numerics. Hope this helps, Craig private void txtValue_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { string s = "0123456789" + (char)8 + (char)9 ; if (s.IndexOf(e.KeyChar.ToString().ToUpper(),0) ==-1) { e.Handled = true; return; } }

          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