Click here to Skip to main content
15,938,218 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I know that, based on the title, this sounds like a beginner question, but i'm running out of ideas.
My application is almost like a desktop widget
you press a hotkey, then it appears
but there's a certain textbox that i would like to receive focus
no matter what i've tried, it refuses to.
The tab index is 0
any time the form is called, i use the TextBox1.Focus() and the TextBox1.Select() functions, but to no avail.
upon pressing the hotkey, something in the background is usually selected
for instance, when i press it on the desktop, something with the corresponding letter in the hotkey
this is really frustrating
i've found a Mac Spotlight emulator capable of doing just what i need, but i just can't seem to get it accomplished in my application.
any suggestions?

ok yeah, sorry. this is the first thing i've ever posted here :/
and yeah, like i said, the tab index is 0.
i'm writing in VB.Net, though i can translate from C#
Updated 29-Aug-10 2:38am
Sandeep Mewara 29-Aug-10 3:33am    
Can you update the tags of the question properly? Web or Winforms? C#?

1 solution

When you say "you press a hotkey, then it appears" I assume you mean when you press a hotkey your App runs and the form is created.
If so, try setting the TabIndex of the control you want to start the cursor in to 0, and check that none of the labels on your form contain a "&" character - if they do the following character will display underlined and will act as a quick key combination. If this matches the hot key to start the app that could switch the focus to a different control.
Share this answer
I, the Deceiver 29-Aug-10 8:54am    
ok, well i've fixed the problem.
i, instead, used the Activate() function thing.
but, since you're the only one who answered, i'll accept your solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900