Solved

c# remove focus from text box

Posted on 2011-02-21
3
1,902 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 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now