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. KeyPress Event for TextBox

KeyPress Event for TextBox

Scheduled Pinned Locked Moved C#
csharphelp
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.
  • A Offline
    A Offline
    aaraaayen 0
    wrote on last edited by
    #1

    Hi Friends, I am working in C# Windows Application 2.0. In my page, i am having 2 textboxes. But when i add keypress event for textbox1 nothing happening at runtime. my code: private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (System.Char)Keys.Enter) { //SendKeys.Send((System.Char)Keys.Tab); MessageBox.Show("Hi"); } } Please help me. Thanks in Advance, Regards,

    Prya

    C Q A 3 Replies Last reply
    0
    • A aaraaayen 0

      Hi Friends, I am working in C# Windows Application 2.0. In my page, i am having 2 textboxes. But when i add keypress event for textbox1 nothing happening at runtime. my code: private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (System.Char)Keys.Enter) { //SendKeys.Send((System.Char)Keys.Tab); MessageBox.Show("Hi"); } } Please help me. Thanks in Advance, Regards,

      Prya

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

      I thnk there's a property on the textbox that makes the textbox register the enter key.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      1 Reply Last reply
      0
      • A aaraaayen 0

        Hi Friends, I am working in C# Windows Application 2.0. In my page, i am having 2 textboxes. But when i add keypress event for textbox1 nothing happening at runtime. my code: private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (System.Char)Keys.Enter) { //SendKeys.Send((System.Char)Keys.Tab); MessageBox.Show("Hi"); } } Please help me. Thanks in Advance, Regards,

        Prya

        Q Offline
        Q Offline
        quiteSmart
        wrote on last edited by
        #3

        Use the KeyDown event instead of the KeyPress and write in it: if(e.KeyCode == Keys.Enter)

        1 Reply Last reply
        0
        • A aaraaayen 0

          Hi Friends, I am working in C# Windows Application 2.0. In my page, i am having 2 textboxes. But when i add keypress event for textbox1 nothing happening at runtime. my code: private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if (e.KeyChar == (System.Char)Keys.Enter) { //SendKeys.Send((System.Char)Keys.Tab); MessageBox.Show("Hi"); } } Please help me. Thanks in Advance, Regards,

          Prya

          A Offline
          A Offline
          aSarafian
          wrote on last edited by
          #4

          You mean not even a MessageBox appears? In this case the event is the event properly set to this function? There is a project ControlInspector[^] that i found very usefull. It might help you in this situations.

          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