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. Bypass character in textbox

Bypass character in textbox

Scheduled Pinned Locked Moved C#
tutorial
6 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.
  • E Offline
    E Offline
    Edwin Syarief
    wrote on last edited by
    #1

    Hi, How to bypass character in TextBox, so when we press alphabet keyboard key will bypass it. But when we press number TextBox will confirm this input. Thanx in advanced

    Regard, Edwin :)

    B N E 3 Replies Last reply
    0
    • E Edwin Syarief

      Hi, How to bypass character in TextBox, so when we press alphabet keyboard key will bypass it. But when we press number TextBox will confirm this input. Thanx in advanced

      Regard, Edwin :)

      B Offline
      B Offline
      BoBo
      wrote on last edited by
      #2

      private void txtBox__KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsDigit(e.KeyChar)) { e.Handled = true; // input is not passed on to the control(TextBox) } }

      E 1 Reply Last reply
      0
      • B BoBo

        private void txtBox__KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsDigit(e.KeyChar)) { e.Handled = true; // input is not passed on to the control(TextBox) } }

        E Offline
        E Offline
        Edwin Syarief
        wrote on last edited by
        #3

        Thanx a lot -Bobo God Bless U

        Regard, Edwin :)

        C 1 Reply Last reply
        0
        • E Edwin Syarief

          Thanx a lot -Bobo God Bless U

          Regard, Edwin :)

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          You need to do this: if (!Char.IsDigit(e.KeyChar) && !Char.IsControl(e.KeyChar) or otherwise your arrow/delete/etc keys will not work.

          edwin46 wrote:

          There is no KeyChar properties in e

          It is constantly depressing to me, the inability of so many people to use intellisense, or google. Goodness knows what you're doing, but the KeyChar property is most certainly present. http://msdn2.microsoft.com/en-us/library/system.windows.forms.keypresseventargs.handled.aspx[^]

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          1 Reply Last reply
          0
          • E Edwin Syarief

            Hi, How to bypass character in TextBox, so when we press alphabet keyboard key will bypass it. But when we press number TextBox will confirm this input. Thanx in advanced

            Regard, Edwin :)

            N Offline
            N Offline
            Nouman Bhatti
            wrote on last edited by
            #5

            write your code in key press event

            1 Reply Last reply
            0
            • E Edwin Syarief

              Hi, How to bypass character in TextBox, so when we press alphabet keyboard key will bypass it. But when we press number TextBox will confirm this input. Thanx in advanced

              Regard, Edwin :)

              E Offline
              E Offline
              Edwin Syarief
              wrote on last edited by
              #6

              Sorry Guys, It's working 100%

              Regard, Edwin :)

              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