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. tab key in a textbox

tab key in a textbox

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 2 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.
  • F Offline
    F Offline
    felixdisc
    wrote on last edited by
    #1

    Hi, I want to give a value in a textbox when the 'tab' key is pressed in another textbox. My code is this: private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if ( (e.KeyChar.Equals(('\t'))) || (e.KeyChar.Equals(Keys.Tab)) ){ this.textBox2.Text = "hola"; } } But the only way that it works is to set the 'Multiline' and 'AcceptsTab' properties to be true (both properties at the same time, unless it not works). And the problem is that on this way, to press the tab key the focus not change to another textbox. Anybody knows a better way?

    O 1 Reply Last reply
    0
    • F felixdisc

      Hi, I want to give a value in a textbox when the 'tab' key is pressed in another textbox. My code is this: private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if ( (e.KeyChar.Equals(('\t'))) || (e.KeyChar.Equals(Keys.Tab)) ){ this.textBox2.Text = "hola"; } } But the only way that it works is to set the 'Multiline' and 'AcceptsTab' properties to be true (both properties at the same time, unless it not works). And the problem is that on this way, to press the tab key the focus not change to another textbox. Anybody knows a better way?

      O Offline
      O Offline
      OkkiePepernoot
      wrote on last edited by
      #2

      Why not use the Leave or Validated event for this ?

      F 1 Reply Last reply
      0
      • O OkkiePepernoot

        Why not use the Leave or Validated event for this ?

        F Offline
        F Offline
        felixdisc
        wrote on last edited by
        #3

        It is a good alternative. I can use the keyPress event for the intro key, and the Leave event for the tab key. Ok, thanks

        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