提供对添加到 Microsoft Office 菜单的控件的访问。
命名空间: Microsoft.Office.Tools.Ribbon
程序集: Microsoft.Office.Tools.Common(在 Microsoft.Office.Tools.Common.dll 中)
Microsoft.Office.Tools.Common.v4.0.Utilities(在 Microsoft.Office.Tools.Common.v4.0.Utilities.dll 中)
语法
声明
<GuidAttribute("49cea6a9-3670-4ae0-9a36-9305e27f302b")> _
Public Interface RibbonOfficeMenu _
Inherits RibbonComponent, IComponent, IDisposable
[GuidAttribute("49cea6a9-3670-4ae0-9a36-9305e27f302b")]
public interface RibbonOfficeMenu : RibbonComponent,
IComponent, IDisposable
RibbonOfficeMenu 类型公开以下成员。
属性
名称 | 说明 | |
---|---|---|
![]() |
Items | 获取您添加到 Microsoft Office 菜单的功能区控件。 |
![]() |
Name | 获取或设置此 RibbonComponent 的名称。 (继承自 RibbonComponent。) |
![]() |
Parent | 获取一个表示此 RibbonComponent 的父级的 RibbonComponent。 (继承自 RibbonComponent。) |
![]() |
Ribbon | 获取包含控件层次结构的顶级 Ribbon 对象。 (继承自 RibbonComponent。) |
![]() |
RibbonUI | 基础结构。获取 Microsoft Office 应用程序提供给功能区扩展性代码的 IRibbonUI 实例。 (继承自 RibbonComponent。) |
![]() |
Site | 获取或设置与 IComponent 关联的 ISite。 (继承自 IComponent。) |
![]() |
Tag | 获取或设置与此 RibbonComponent 关联的特定于应用程序的数据。 (继承自 RibbonComponent。) |
页首
方法
名称 | 说明 | |
---|---|---|
![]() |
Dispose | 执行与释放或重置非托管资源相关的应用程序定义的任务。 (继承自 IDisposable。) |
![]() |
PerformDynamicLayout | 如果 RibbonComponent 有一个动态父级(如动态菜单)且布局未挂起,则调用父控件的 Microsoft.Office.Core.IRibbonUI.InvalidateControl 方法。 (继承自 RibbonComponent。) |
![]() |
PerformLayout | 如果 RibbonComponent 有父级,并且布局未挂起,则调用 Microsoft.Office.Core.IRibbonUI.InvalidateControl。 (继承自 RibbonComponent。) |
![]() |
ResumeLayout() | 取消 SuspendLayout 方法的效果。 (继承自 RibbonComponent。) |
![]() |
ResumeLayout(Boolean) | 取消 SuspendLayout 方法的效果。 (继承自 RibbonComponent。) |
![]() |
SuspendLayout | 阻止 Microsoft Office 应用程序刷新功能区上的控件的状态。 (继承自 RibbonComponent。) |
页首
事件
名称 | 说明 | |
---|---|---|
![]() |
Disposed | 表示处理组件的 Disposed 事件的方法。 (继承自 IComponent。) |
页首
备注
在向项目中添加**“功能区(可视化设计器)”**项时,Visual Studio 会自动将新的 RibbonOfficeMenu 对象分配给生成的 OfficeRibbon 接口的 OfficeMenu 属性。使用此对象可以在运行时将新控件添加到 Microsoft Office 菜单,或者访问已添加到 Microsoft Office 菜单的控件。
可以在运行时添加控件,但只能在加载功能区之前添加。创建该控件的实例,然后将新控件添加到 Items 集合。有关更多信息,请参见功能区对象模型概述。
![]() |
---|
此接口由 Visual Studio Tools for Office Runtime 实现。不应在代码中实现此接口。有关更多信息,请参见 Visual Studio Tools for Office Runtime 概述。 |
用法
本文档介绍面向 .NET Framework 4 和 .NET Framework 4.5 的 Office 项目中所用此类型的版本。在面向 .NET Framework 3.5 的项目中,此类型可能具有不同的成员,因此本文档为此类型提供的代码示例可能并不适用。有关面向 .NET Framework 3.5 的项目中的此类型的文档,请参见 Visual Studio 2008 文档中的以下参考部分:https://go.microsoft.com/fwlink/?LinkId=160658。
示例
下面的示例循环访问“功能区”Office 菜单上的自定义控件并显示它们的名称。若要运行此代码示例,必须先执行下列步骤:
将一个**“功能区(可视化设计器)”**项添加到 Office 项目中。
向“Microsoft Office 按钮”添加一个按钮。
将该按钮的**“(Name)”**属性设置为 myOfficeMenuButton。
将**“PositionType”属性设置为“Position”属性下的“AfterOfficeID”**。
将**“OfficeID”属性设置为“Position”属性下的“FilePrintMenu”**。
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
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);
}
}
请参见
参考
Microsoft.Office.Tools.Ribbon 命名空间