RibbonFactory.CreateRibbonMenu, méthode
Crée un RibbonMenu représentant un menu sur un onglet du ruban ou dans le menu Microsoft Office.
Espace de noms : Microsoft.Office.Tools.Ribbon
Assembly : Microsoft.Office.Tools.Common (dans Microsoft.Office.Tools.Common.dll)
Syntaxe
'Déclaration
Function CreateRibbonMenu As RibbonMenu
RibbonMenu CreateRibbonMenu()
Valeur de retour
Type : Microsoft.Office.Tools.Ribbon.RibbonMenu
Menu du ruban.
Exemples
L'exemple suivant crée un menu à l'aide de la méthode CreateRibbonMenu.
Private Sub PopulateCustomerMenu()
' Add two sub-menus to EmployeeMenu and populate each sub-menu
' First sub-menu
Dim subMenu1 As RibbonMenu = Me.Factory.CreateRibbonMenu()
subMenu1.Dynamic = True
subMenu1.Label = "A - M"
subMenu1.Items.Add(Me.Factory.CreateRibbonToggleButton())
CType(subMenu1.Items.Last(), RibbonToggleButton).Label = "Hall, Don"
subMenu1.Items.Add(Me.Factory.CreateRibbonToggleButton())
CType(subMenu1.Items.Last(), RibbonToggleButton).Label = "Valdez, Rachel"
CustomerMenu.Items.Add(subMenu1)
' Second sub-menu
Dim subMenu2 As RibbonMenu = Me.Factory.CreateRibbonMenu()
subMenu2.Dynamic = True
subMenu2.Label = "N - Z"
subMenu2.Items.Add(Me.Factory.CreateRibbonToggleButton())
CType(subMenu2.Items.Last(), RibbonToggleButton).Label = "Robinson, Alex"
CustomerMenu.Items.Add(subMenu2)
End Sub
private void PopulateCustomerMenu()
{
// Add two sub-menus to EmployeeMenu and populate each sub-menu
// First sub-menu
RibbonMenu subMenu1 = this.Factory.CreateRibbonMenu();
subMenu1.Dynamic = true;
subMenu1.Label = "A - M";
subMenu1.Items.Add(this.Factory.CreateRibbonToggleButton());
((RibbonToggleButton)subMenu1.Items.Last()).Label = "Hall, Don";
subMenu1.Items.Add(this.Factory.CreateRibbonToggleButton());
((RibbonToggleButton)subMenu1.Items.Last()).Label = "Valdez, Rachel";
CustomerMenu.Items.Add(subMenu1);
// Second sub-menu
RibbonMenu subMenu2 = this.Factory.CreateRibbonMenu();
subMenu2.Dynamic = true;
subMenu2.Label = "N - Z";
subMenu2.Items.Add(this.Factory.CreateRibbonToggleButton());
((RibbonToggleButton)subMenu2.Items.Last()).Label = "Robinson, Alex";
CustomerMenu.Items.Add(subMenu2);
}
Sécurité .NET Framework
- Confiance totale accordée à l'appelant immédiat. Ce membre ne peut pas être utilisé par du code d'un niveau de confiance partiel. Pour plus d'informations, consultez Utilisation de bibliothèques à partir de code d'un niveau de confiance partiel.