Solved

c# remove focus from text box

Posted on 2011-02-21
3
2,124 Views
Last Modified: 2013-12-17
Hi,

In my form, I have a button, and a list box. Wheneve my form loaded, the cursor is always pointed to text box. How can redirect this cursor so that I can implement keydown process where a user can press space bar or enter key to exit my app?

Thanks,
JT
0
Comment
Question by:jtran007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 125 total points
ID: 34943100
There should be a form property - preview keys, set this to true then add a keydown handler to the form and put your code there to handle space bar (and other keys).

Or just change the tab order so the listbox is the first control if that is suitable for your needs
0
 
LVL 9

Assisted Solution

by:s_chilkury
s_chilkury earned 125 total points
ID: 34943111
The TabIndex property of the textbox is 0. This sets the focus on textbox as soon as the form is loaded.

Set the TabIndex property of any other label to 0 which will serve your purpose.
0
 

Author Closing Comment

by:jtran007
ID: 34943544
Thanks,
JT
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question