• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

Controlling tab key in groupboxes


Our application is .NEt 2.0 c# Winforms

I would like to know if there's a mean to control the behavior of the tab key in a usercontrol.  In majority of cases it's easy when using TabIndex and TabStop property.

A request has been made to modify the tab  order of one of usercontrol. The problem is taht the tab order requested is jumping from a control in a groupbox to another to come back to the previous group box.

Removing groupbox is not an option. Changing controls order to fit is not an option too, because some customers want the behavior and others not.

For example, in a user control we have GroupBoxA with control A and B. We have another groupbox B with control C and E.

Tab key should move from control A to C to B to E. As far as i know, this is not possible to achieve in a "normal" tab index feature because GroupBox have their tab index and the controls within it are "child" of the tab index.

What can I do to solve this?

Let me know if my question is unclear or for additional information.

Thanks in advance.
1 Solution
David Johnson, CD, MVPOwnerCommented:
I don't think you can either. (Sorry for the very unhelpful response)
Bob LearnedCommented:
I haven't done Windows Forms forms in a while, but there was a way to handle custom tab order by intercepting the WM_KEYDOWN message in the form's ProcessCmdKey, and defining your own custom tab order, so that the system would know which control to set focus to.
If you do not need the GroupBoxes from the programaticall object model point of view, and they have to be there only for the visual apperance, then create the TextBoxes as not being the children objects of the aforementioned GroupBoxes, but they will be only the children of the parent Form/Panel/.../object where the GroupBoxes are within, but they will be displayed in front of them (to achieve this mos simply, move the text boxes USING THE MOUSE OUT of the group boxes and then move them back OVER the GROUP BOXES using the ARROW KEYS). Should they disappear, right click the GroupBox that has hidden them/it and select "Send to back".
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now