How to control the focus as the user tabs into a user control?

How to control the focus as the user tabs into a user control?

Post by Mitc » Sat, 08 Jun 2002 06:08:11



I have a form with a textbox, two user controls and an OK button. Each user
control has a button and a dataGrid.  When  the focus moves to the user
control, the tabbing behavior inside the user control is unpredictable.
sometimes the focus goes to the button, then the datagrid, and sometimes the
focus goes to the button, then out of the control. I am explicitly setting
the tabindex values for each control, An I've also set the Z-orders but to
know avail.

Can someone explain how to control how the focus moves when the tab key is
pressed.

Thanks

Mitch

 
 
 

How to control the focus as the user tabs into a user control?

Post by Jens Grusche » Sat, 08 Jun 2002 16:34:11


Quote:> Can someone explain how to control how the focus moves when the tab key is
> pressed.

Don't know for sure, but maybe this helps: Create a descendant of
UserControl and add following code:

protected override bool ProcessTabKey(bool forward)
{
  bool r = false;
  if (this.ActiveControl != null) r =
this.SelectNextControl(this.ActiveControl,forward,true,true,false);
  if (!r) r = this.Parent.SelectNextControl(this,forward,true,true,false);
// last parameter might also be true
  return r;

Quote:}

Jens

 
 
 

How to control the focus as the user tabs into a user control?

Post by Laurie Pauli » Sat, 08 Jun 2002 17:45:10


I have a similar problem when there is a user control within a user control
on a form.  I (and others) have reported this several times with no reponse
from MS.  The solution for me was to only have the UC on an inherited form,
i.e. reduce the number of levels.

It seems like this is a bit different from your problem as you only have one
level but it is becoming apparent that there are problems with tabs and UC.
As SP2 is slated for Sep this year, you may have to re-architect your app.

Laurie Paulin
Perth, Western Australia


Quote:> I have a form with a textbox, two user controls and an OK button. Each
user
> control has a button and a dataGrid.  When  the focus moves to the user
> control, the tabbing behavior inside the user control is unpredictable.
> sometimes the focus goes to the button, then the datagrid, and sometimes
the
> focus goes to the button, then out of the control. I am explicitly setting
> the tabindex values for each control, An I've also set the Z-orders but to
> know avail.

> Can someone explain how to control how the focus moves when the tab key is
> pressed.

> Thanks

> Mitch

 
 
 

How to control the focus as the user tabs into a user control?

Post by Jens Grusche » Sat, 08 Jun 2002 18:39:17


Maybe this one is better - and more easy to understand. To be honest, I
don't know any more why I added the additional logic, it seems to work
without it.

protected override bool ProcessTabKey(bool forward)
{
  return this.Parent.SelectNextControl(this,forward,true,true,false);

Quote:}

Maybe you might also want to override OnGotFocus and/or the Focused
property.

Jens

 
 
 

How to control the focus as the user tabs into a user control?

Post by Jens Grusche » Sat, 08 Jun 2002 18:52:43


It's me again. Take the first code I posted. The second one does only work
when not more than one control is child of your user control.

Jens

 
 
 

How to control the focus as the user tabs into a user control?

Post by Mitc » Sun, 09 Jun 2002 06:29:51


Actually, the user control I mentioned is in another user control. I didn't
mention that initially because I wanted to keep the question simple. So it
sounds like MS has some bugs to fix in this area.

Have you tried any of Jens suggested code. Does it help the control within a
control problem.

Thanks.

Mitch


> I have a similar problem when there is a user control within a user
control
> on a form.  I (and others) have reported this several times with no
reponse
> from MS.  The solution for me was to only have the UC on an inherited
form,
> i.e. reduce the number of levels.

> It seems like this is a bit different from your problem as you only have
one
> level but it is becoming apparent that there are problems with tabs and
UC.
> As SP2 is slated for Sep this year, you may have to re-architect your app.

> Laurie Paulin
> Perth, Western Australia



> > I have a form with a textbox, two user controls and an OK button. Each
> user
> > control has a button and a dataGrid.  When  the focus moves to the user
> > control, the tabbing behavior inside the user control is unpredictable.
> > sometimes the focus goes to the button, then the datagrid, and sometimes
> the
> > focus goes to the button, then out of the control. I am explicitly
setting
> > the tabindex values for each control, An I've also set the Z-orders but
to
> > know avail.

> > Can someone explain how to control how the focus moves when the tab key
is
> > pressed.

> > Thanks

> > Mitch

 
 
 

1. Problem with Infragisitic Tab control and User Control

C#.NET Viusal Studio 2003. When using Infragistics controls i.e.
Infragistics.Win.UltraWinTabControl.UltraTabControl, they  disappear
whenever I change the code of the form where they are used. Also in the
run mode these contols can't be seen.
The same applies to the User Controls. But the only difference is that
when we open its resource file after embedding the contols on the
Window Form, they are not seen there anymore.
Can any one help me in this regard ?

2. Which is better Procmail or Deliver

3. user control in tab control -> OnLoad called -> boom!

4. Post dialup dialog problem - typing locks up system

5. Order of operations for user controls in a multipage tab control.

6. Template Search

7. Compiled user controls not in my user controls toolbox...

8. acessing environ for a process

9. Accessing Other User Controls and Parents From User Control

10. Calling an user control from another user control

11. web user control within a web user control

12. I have a user control and I want to inherit it from another user control

13. Access user control property in same user control .ascx code