Microsoft KB Archive/196902

= BUG: UserControl Does Not Refresh the Menu =

Article ID: 196902

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q196902



SYMPTOMS
If a UserControl changes the menu at run time, the menu does not refresh.



RESOLUTION
You need to set the Enabled property of the UserControl to False, reset it to True, and then given it the focus to force a refresh of the menu.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 Start a New ActiveX Control Project. UserControl1 is created by default. From the Tools menu, click the Menu Editor. Add the following three menu items:

    - Caption : Menu1 - Name : Menu1 - NegotiatePosition = Left     - Caption : SubMenu1 - Name : SubMenu1 - Click the Right Arrow button to make it a SubMenu.  <pre class="fixed_text">   - Caption : Menu2 - Name : Menu2 - NegotiatePostion = Left </li></ul> </li>  Add a CommandButton (Command1) to the UserControl. Add the following code to the General Declarations section of UserControl1: Private Sub Command1_Click Menu1.Caption = "Modified" End Sub </li> Close all open windows on Project1.</li> From the File menu, click Add Project to add a New Standard .exe Project. Form1 is created by default.</li> Place an instance of UserControl1 to Form1, and run the project.</li> Click the CommandButton on the UserControl. The caption of Menu1 does not change.</li>  To work around the problem replace the code in UserControl1 with the following: Private Sub Command1_Click Menu1.Caption = "Modified" UserControl.Enabled = False UserControl.Enabled = True UserControl.SetFocus DoEvents End Sub </li> Close Project1 and repeat Step 7. The menu caption is updated.</li></ol>

Additional query words: UserControl Menu Refresh

Keywords: kbbug kbnofix kbctrlcreate kbcode KB196902

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.