BUG: Focus is on the hidden child control while the Visible property of the parent is set to False (814348)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# 2005, Express Edition
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
SYMPTOMSYou can set the Visible property of a parent control to False at run
time. If you do this, the focus is not set to any visible control. The focus is
not moved to the next visible control in the tab order. For example, you have a
Button control in a Panel control. At run time, you set the Visible property of the panel to False on the Click event procedure of the Button control. The focus is still on the Button control. The focus is not moved to the next visible control. This
occurs when you hide the parent control.CAUSEWhen the focus is on a child control and you hide the parent
control, the focus moves to the first child of the parent control. Therefore,
the focus remains on the hidden control. The focus is not moved to the next
visible control on the form.WORKAROUNDTo work around this bug, set the focus to the next visible
control on the form. You must do this either before or after you hide the
parent control. To set the focus to the next visible control on the form,
follow these steps:
- Double-click Button1. Replace the existing
code with the following code:
Visual Basic .NET or Visual Basic 2005 Code' Hide the Parent control
Me.Button1.Parent.Visible = False
' Set the Focus to next control
SelectNextControl(Button1, True, True, True, True) Visual C# .NET or Visual C# 2005 Code// Hide the Parent control
this.button1.Parent.Visible = false;
// Set the Focus to next control
SelectNextControl(button1,true,true,true,true); - Double-click Button2. Replace the existing
code with the following code:
Visual Basic .NET or Visual Basic 2005 Code' Set the Focus to next control
SelectNextControl(Button2, True, True, True, True)
' Hide the Parent control
Me.Button2.Parent.Visible = False
Visual C# .NET or Visual C# 2005 Code// Set the Focus to next control
SelectNextControl(button2,true,true,true,true);
// Hide the Parent control
this.button2.Parent.Visible = false;
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are
listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005applies kbvs2005swept kbvs2002sp1sweep kbProperties kbControl kbContainer kbbug KB814348 kbAudDeveloper |
---|
|