BUG: UserControl Does Not Refresh the Menu
ID: Q196902
|
The information in this article applies to:
-
Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0
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.
MORE INFORMATION
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.
- Caption : Menu2
- Name : Menu2
- NegotiatePostion = Left
- 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
- Close all open windows on Project1.
- From the File menu, click Add Project to add a New Standard .exe
Project. Form1 is created by default.
- Place an instance of UserControl1 to Form1, and run the project.
- Click the CommandButton on the UserControl. The caption of Menu1 does
not change.
- 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
- Close Project1 and repeat Step 7. The menu caption is updated.
Additional query words:
UserControl Menu Refresh
Keywords : kbCtrlCreate kbVBp500bug kbVBp600bug kbGrpVB kbCodeSam
Version : WINDOWS:5.0,6.0
Platform : WINDOWS
Issue type : kbbug