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. how to check if any textbox has changed on a form?

how to check if any textbox has changed on a form?

Scheduled Pinned Locked Moved C#
tutorialquestion
5 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.
  • C Offline
    C Offline
    Cptkli
    wrote on last edited by
    #1

    Hi, i have several textBoxes on a form and i want to set a Boolean to false if a key is pressed in any of them. Is there a quick method to do that instead of "textBox1_KeyPress", "textBox2_KeyPress" ect... ? Thanks in advance :rose:

    G L 2 Replies Last reply
    0
    • C Cptkli

      Hi, i have several textBoxes on a form and i want to set a Boolean to false if a key is pressed in any of them. Is there a quick method to do that instead of "textBox1_KeyPress", "textBox2_KeyPress" ect... ? Thanks in advance :rose:

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      You can have one KeyPress event handler for all of the textboxes

      #region signature my articles #endregion

      1 Reply Last reply
      0
      • C Cptkli

        Hi, i have several textBoxes on a form and i want to set a Boolean to false if a key is pressed in any of them. Is there a quick method to do that instead of "textBox1_KeyPress", "textBox2_KeyPress" ect... ? Thanks in advance :rose:

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        or you may set Form.KeyPreview true and take care of it in Form.OnKeyDown/OnKeyPress (possibly with checking object sender is a TextBox). :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


        C 1 Reply Last reply
        0
        • L Luc Pattyn

          or you may set Form.KeyPreview true and take care of it in Form.OnKeyDown/OnKeyPress (possibly with checking object sender is a TextBox). :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


          C Offline
          C Offline
          Cptkli
          wrote on last edited by
          #4

          Luc Pattyn wrote:

          or you may set Form.KeyPreview true and take care of it in Form.OnKeyDown/OnKeyPress (possibly with checking object sender is a TextBox).

          Thx allot it works. I am also interested in Giorgi solution as i do not know how to do what he tells.

          G 1 Reply Last reply
          0
          • C Cptkli

            Luc Pattyn wrote:

            or you may set Form.KeyPreview true and take care of it in Form.OnKeyDown/OnKeyPress (possibly with checking object sender is a TextBox).

            Thx allot it works. I am also interested in Giorgi solution as i do not know how to do what he tells.

            G Offline
            G Offline
            Giorgi Dalakishvili
            wrote on last edited by
            #5

            If you are using Visual Studio then select the button you want to set event handler for and switch to the event list in properties window. Find the KeyPress event there and choose the event handler you want to attach from the drop-down list. For each button select the same event.

            #region signature my articles #endregion

            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