Dela via


RibbonButton Constructor (2007 System)

Initializes a new instance of the RibbonButton class.

Namespace:  Microsoft.Office.Tools.Ribbon
Assembly:  Microsoft.Office.Tools.Common.v9.0 (in Microsoft.Office.Tools.Common.v9.0.dll)

Syntax

'Declaration
Public Sub New
'Usage
Dim instance As New RibbonButton()
public RibbonButton()
public:
RibbonButton()
public function RibbonButton()

Remarks

Visual Studio Tools for Office creates an instance of this class for you when you drag a Button from the Office Ribbon Controls tab of the Toolbox onto the Ribbon Designer.

You can also create an instance of this control at run time and add it to a dynamic menu.

Examples

The following example creates two instances of the RibbonButton class and adds them to a menu. To run this code example, you must first perform the following steps:

  1. Add a Ribbon (Visual Designer) item to a Visual Studio Tools for Office project.

  2. Add a group to the custom tab.

  3. Add a menu to the group.

  4. Set the Dynamic property of the menu to true.

Private Sub PopulateDynamicMenu()
    menu1.Items.Add(New RibbonButton())
    CType(menu1.Items.Last(), RibbonButton).Label = "Button 1"
    menu1.Items.Add(New RibbonButton())
    CType(menu1.Items.Last(), RibbonButton).Label = "Button 2" 
End Sub
private void PopulateDynamicMenu()
{
    menu1.Items.Add(new RibbonButton());
    ((RibbonButton)menu1.Items.Last()).Label = "Button 1";
    menu1.Items.Add(new RibbonButton());
    ((RibbonButton)menu1.Items.Last()).Label = "Button 2";
}

.NET Framework Security

See Also

Reference

RibbonButton Class

RibbonButton Members

Microsoft.Office.Tools.Ribbon Namespace

Other Resources

Ribbon Overview

Ribbon Object Model Overview