Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

c# remove focus from text box

Posted on 2011-02-21
3
Medium Priority
?
2,368 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
3 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 500 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 500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

916 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