Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hi,

In windows application ,
I have a textbox1 which I make it invisible on selecting a radio button and make another textbox2 visible.
when I select the radio button, on tabbing i should get focus to textbox2 but the textbox1 gets focus and on next tab textbox2 gets focus.

How to make the invisible textbox not to get focus on tabbing?
Posted

Perhaps you are not really hiding the control, and instead you just obscure it from view by showing another control above it? That may explain why it gets focus. If so, the solution is to actually hide it by setting Visible to false.
 
Share this answer
 
Comments
Espen Harlinn 16-Feb-11 15:10pm    
Sounds reasonable, disabling it could also help if this is the case - my 5
textBox1.TabStop = false;

you can find it on textbox1's properties window too.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 16-Feb-11 13:46pm    
Basically correct but redundant for invisible controls, see my answer.
--SA
#realJSOP 16-Feb-11 14:17pm    
Not the correct approach.
The Answer by amcanomer is correct. However, if control is not visible, it will not participate in tab navigation (or any other focusing activity) anyway, so you don't have to handle the situation at all.

—SA
 
Share this answer
 
If it's not visible or is not enabled, it won't get the focus when the user tabs around the form.

If yours does, you're doing something very wrong.
 
Share this answer
 
That should not happen, but even that is happening, try this too

C#
TextBox1.Enable = false;
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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