Asked by:
Modify the caption of a CommandBarButton

Question
-
Is there a way to modify the caption of a Command Bar Button programmatically after the right-click and before the appearance of the button?
When you right-click on a form control to expose the custom popup menu, I want to be able to check the status of a certain variable and alter the caption of a Command Bar Button before it becomes visible, similar to True = "Change", False = "Restore" Is there a way to do that?
Monday, March 13, 2017 10:30 PM
All replies
-
Hi,
Yes, I believe there is a way to do it if you're using a custom toolbar or command bar. Are you?
Monday, March 13, 2017 10:35 PM -
Hi GLBybee,
you had mentioned that you want to check some variable on form control to check the status of variable.
I think that you should add an option to context menu and if user click then execute the code and check the status and make the button visible.
if you just execute the code on right click then may be it is possible that it executes always , in that situation also when you don't want to execute it.
you can try to add option in context menu by using xml code.
Regards
Deepak
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Tuesday, March 14, 2017 3:06 AM -
The closest that I can think of is the MouseMove event to change the caption of the button. I don't know about the newer version for the command bars.Tuesday, March 14, 2017 4:19 AM
-
Yes, it is a custom shortcut popup menu, visible when you right-click on a certain control on a form.Tuesday, March 14, 2017 3:51 PM
-
The MouseMove event would only change something visible at the time of the mouse move. If we are talking about a shortcut menu bar, it won't become visible until you right-click on the control.
I thought about trying the MouseDown event and checking if the mouse down was a right-click and making the programmatic changes then.
I was more interested in finding out if there was some event I was not aware of that would trigger between the right- click and the visibility of the shortcut menu button.
Tuesday, March 14, 2017 3:58 PM -
Yes, it is a custom shortcut popup menu, visible when you right-click on a certain control on a form.
Then you might try something like: CommandBars("ShortcutName").Controls(1).Caption="New Value" Hope it helps...Tuesday, March 14, 2017 7:15 PM -
That sounds good, but my problem is knowing where to put that instruction, and what triggers it.Tuesday, March 14, 2017 9:16 PM
-
That sounds good, but my problem is knowing where to put that instruction, and what triggers it.
I know I have an example somewhere. I'll try to dig it up.Wednesday, March 15, 2017 12:02 AM