RibbonOfficeMenu 接口

定义

提供对添加到 Microsoft Office 菜单的控件的访问。

public interface class RibbonOfficeMenu : IDisposable, Microsoft::Office::Tools::Ribbon::RibbonComponent, System::ComponentModel::IComponent
[System.Runtime.InteropServices.Guid("49cea6a9-3670-4ae0-9a36-9305e27f302b")]
public interface RibbonOfficeMenu : IDisposable, Microsoft.Office.Tools.Ribbon.RibbonComponent, System.ComponentModel.IComponent
[<System.Runtime.InteropServices.Guid("49cea6a9-3670-4ae0-9a36-9305e27f302b")>]
type RibbonOfficeMenu = interface
    interface RibbonComponent
    interface IComponent
    interface IDisposable
Public Interface RibbonOfficeMenu
Implements IComponent, IDisposable, RibbonComponent
属性
实现

示例

以下示例循环访问功能区 Office 菜单上的自定义控件并显示其名称。 若要运行此代码示例,必须先执行以下步骤:

  1. 功能区 (Visual Designer) 项添加到 Office 项目。

  2. 将按钮添加到 Microsoft Office 按钮。

  3. 将按钮 的 (Name) 属性设置为 myOfficeMenuButton

  4. 在 Position 属性下,将 PositionType属性设置为AfterOfficeID

  5. Position 属性下,将 OfficeID 属性设置为 FilePrintMenu

private void ListOfficeRibbonCustomControls()
{
    System.Windows.Forms.MessageBox.Show(
        "Listing all Office Menu custom controls...");
    foreach (RibbonComponent control in Globals.Ribbons.Ribbon1.OfficeMenu.Items)
    {
        System.Windows.Forms.MessageBox.Show("Control name: " + control.Name);
    }
}
Private Sub ListOfficeRibbonCustomControls()
    System.Windows.Forms.MessageBox.Show( _
            "Listing all Office Menu custom controls...")
    For Each control As RibbonComponent In Globals.Ribbons.Ribbon1.OfficeMenu.Items
        System.Windows.Forms.MessageBox.Show("Control name: " + control.Name)
    Next
End Sub

注解

功能区 (Visual Designer) 项添加到项目时,Visual Studio 会自动将新RibbonOfficeMenu对象OfficeMenu分配给生成的OfficeRibbon接口的 属性。 使用此对象可在运行时将新控件添加到 Microsoft Office 菜单,或访问添加到 Microsoft Office 菜单的控件。

可以在运行时添加控件,但只能在加载功能区之前添加控件。 创建控件的实例,然后将新控件添加到集合。Items 有关详细信息,请参阅 功能区对象模型概述

注意

此接口由 Visual Studio Tools for Office Runtime 实现。 不应在代码中实现此接口。 有关更多信息,请参见 Visual Studio Tools for Office Runtime Overview

使用情况

本文档介绍面向 .NET Framework 4 或更高版本的 Office 项目中所用的此类型的版本。 在面向 .NET Framework 3.5 的项目中,此类型可能具有不同的成员,因此本文档为此类型提供的代码示例可能并不适用。 有关在面向 .NET Framework 3.5 的项目中使用此类型的文档,请参阅 Visual Studio 2008 文档中的以下参考部分:http://go.microsoft.com/fwlink/?LinkId=160658

属性

Items

获取添加到 Microsoft Office 菜单的功能区控件。

Name

获取或设置此 RibbonComponent 的名称。

(继承自 RibbonComponent)
Parent

获取一个 RibbonComponent,表示此 RibbonComponent 的父级。

(继承自 RibbonComponent)
Ribbon

获取包含控件层次结构的顶级 Ribbon 对象。

(继承自 RibbonComponent)
RibbonUI

获取 Microsoft Office 应用程序提供给功能区扩展性代码的 IRibbonUI 实例。

(继承自 RibbonComponent)
Tag

获取或设置与此 RibbonComponent 关联的应用程序特定的数据。

(继承自 RibbonComponent)

方法

PerformDynamicLayout()

如果 RibbonComponent 具有一个动态父级(如动态菜单)且布局未挂起,则调用父控件的 Microsoft.Office.Core.IRibbonUI.InvalidateControl 方法。

(继承自 RibbonComponent)
PerformLayout()

如果 具有一个父级,且布局未挂起,则调用 RibbonComponentMicrosoft.Office.Core.IRibbonUI.InvalidateControl。

(继承自 RibbonComponent)
ResumeLayout()

取消 SuspendLayout() 方法的效果。

(继承自 RibbonComponent)
ResumeLayout(Boolean)

取消 SuspendLayout() 方法的效果。

(继承自 RibbonComponent)
SuspendLayout()

阻止 Microsoft Office 应用程序刷新功能区上的控件状态。

(继承自 RibbonComponent)

适用于