You cannot set the focus to the child controls of a user control by using the TAB key (820628)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
- Microsoft .NET Framework 2.0
- Microsoft .NET Framework 1.1
- Microsoft .NET Framework 1.0
SYMPTOMSIn Microsoft Visual Basic .NET or Microsoft Visual Basic 2005, you create a Windows form
that has a user control, and then you set the TabStop property of the user control to False (false in Microsoft Visual C# .NET). When you run the application, you
cannot set the focus on the child controls of the user control by pressing the
TAB key. This behavior occurs even when the TabStop property is set to True (true in Visual C# .NET) for the child controls.CAUSEThe UserControl class inherits from the ContainerControl class. The GroupBox class, Panel class, and TabControl class inherit from the Control class. Microsoft .NET Framework interprets the TabStop property for user controls in a different way then it interprets
the TabStop property for GroupBox, Panel, and TabControl. Because of the way .NET Framework interprets the TabStop property, this behavior may seem inconsistent.WORKAROUNDTo work around this problem, set the TabStop property of the user control to True. To do this, follow these steps:
- In Visual Basic .NET or Visual Basic 2005, open Form1.vb (in Visual C# .NET,
open Form1.cs).
- Locate and replace the following code.
Visual Basic .NET or Visual Basic 2005 code
ReplaceMyControl.TabStop = False with MyControl.TabStop = True Visual C# .NET code
ReplaceMyControl.TabStop = false; with MyControl.TabStop = true; - On the Debug menu, click
Start to run the application.
Form1 is
displayed. - Press the TAB key several times to set the focus to the
buttons on Form1.
You can set the focus to the two buttons that are
the MyControl child controls. Note These steps are based on the sample from the "More Information"
section of this article. Therefore, the code and the file names in these steps
may differ from your code and your file names. STATUS This
behavior is by design.REFERENCESFor more information, visit the following Microsoft
Developer Network (MSDN) Web sites:
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbTabCtrl kbButton kbCtrlCreate kbWindowsForms kbForms kbCtrl kbControl kbSample kbProgramming kbprb KB820628 kbAudDeveloper |
---|
|