How to set focus on text box and command button(focus the both the same event)-VBForums
Results 1 to 2 of 2

Thread: How to set focus on text box and command button(focus the both the same event)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    20

    How to set focus on text box and command button(focus the both the same event)

    Hi all, I am using vb.net coding. I want to set focus on text box to type in text box and focus on command button in the same time.

    For example, I have one text box and one command button.

    when my form running i want to send cursor to text box to input data and i want to set focus on command button at the same moment(focus on text box and command button). It means when i am typing in text box another command button is focus as well. How can we do like this? please help me.

    thank so much.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    86,101

    Re: How to set focus on text box and command button(focus the both the same event)

    It's not possible. Only one control can have focus at a time.

    Why exactly do you want to do this? Is it so you can just press Enter to "press" the Button when you're done typing? If so then just assign the Button to the form's AcceptButton property. That way that Button will respond as though clicked whenever you press Enter and the control with focus doesn't itself respond to that key.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.