Custom Buttons Hide/Visible how does it work

Discussions related to SoftPro Select user interface development.

Moderator: Phil Barton

Post Reply
dflood2
Posts: 12
Joined: Thu Mar 11, 2010 12:11 pm

Custom Buttons Hide/Visible how does it work

Post by dflood2 »

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
Hadi Chemaly

Re: Custom Buttons Hide/Visible how does it work

Post by Hadi Chemaly »

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:

Code: Select all

base.RegisterHandler(Package.MyButton, this.MyButton_Invoked, this.MyButton_QueryStatus);
Then implement MyButton_QueryStatus to enable/disable the button appropriately:

Code: Select all

private void MyButton_QueryStatus(object sender, EventArgs e)
{
    Command cmd = (Command)sender;
    cmd.Enabled = ... ;  //enable/disable button based on user profile
}
Post Reply