Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
In a Form I am using a user control and few textboxes.
User control has 2 link labels and a spread Tab Sequence for Controls in User Control(Link1,Link2,Spread).
When the form loads the initial focus should be on first cell of the Spread.
Tab sequence should be spread,Textbox1,textbo2,textbox3,link1,link2.

But The inital focus is on Link1 instead of focusing on spread. Then on tabbing the focus navigates to Link2,Spread,textbox1,textbox2,textbox3.
How to set the initail focus to Spread?

Can we use ActiveControl or Focus?
I am trying ActiveControl but not sure whether it is correct way.
Ex:
this.UserControl1.ActiveControl = this.UserControl1.Spread;

Thank u in advance.
Posted
Comments
Sergey Alexandrovich Kryukov 24-Feb-11 14:01pm    
Looks correct. Maybe your problem is not focus but also selection.
--SA
sony_cute6 24-Feb-11 14:13pm    
does ActiveControl work for this

1) Open your control in the designer.
2) Select "View...Tab Order" from the menu.
3) Re-order your controls so the the numbers run from 0 (the control you want to start with) and increase by one to the next in the tab order you want, but clicking the first one, then the second, and so on.
4) Exit the Tab order change by selecting "View...Tab Order" again.
5) Rebuild your control.

There is also a button on the "Layout" toolbar to enter / exit tab order mode.
 
Share this answer
 
Hi there, have you tried Spread.Focus() rather than ActiveControl? I normally use the Focus method and it works fine :P
 
Share this answer
 

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