Solved

c# remove focus from text box

Posted on 2011-02-21
3
2,205 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

626 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