We have a custom package with many buttons in it we would like to display some buttons but not all based on user profile. How can we hide or make visible buttons.
Thanks
David
Custom Buttons Hide/Visible how does it work
Moderator: Phil Barton
Re: Custom Buttons Hide/Visible how does it work
You cannot hide ribbon buttons as that would violate the 2007 MICROSOFT® OFFICE FLUENT™ USER INTERFACE DESIGN GUIDELINES. What you can do is disable buttons based on user profiles by overriding the button's QueryStatus handler in your package class.
First, register your button handler in the package class constructor:
Then implement MyButton_QueryStatus to enable/disable the button appropriately:
First, register your button handler in the package class constructor:
Code: Select all
base.RegisterHandler(Package.MyButton, this.MyButton_Invoked, this.MyButton_QueryStatus);
Code: Select all
private void MyButton_QueryStatus(object sender, EventArgs e)
{
Command cmd = (Command)sender;
cmd.Enabled = ... ; //enable/disable button based on user profile
}