共用方式為


RibbonOfficeMenu 介面

可讓您存取您加入至 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 的父代 (Parent)。 (繼承自 RibbonComponent)。
公用屬性 Ribbon 取得包含控制項階層架構的最上層 Ribbon 物件。 (繼承自 RibbonComponent)。
公用屬性 RibbonUI 基礎架構。取得 Microsoft Office 應用程式提供給功能區擴充性程式碼的 IRibbonUI 執行個體。 (繼承自 RibbonComponent)。
公用屬性 Site 取得或設定與 IComponent 相關聯的 ISite。 (繼承自 IComponent)。
公用屬性 Tag 取得或設定與這個 RibbonComponent 關聯的應用程式特定資料。 (繼承自 RibbonComponent)。

回頁首

方法

  名稱 說明
公用方法 Dispose 執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。 (繼承自 IDisposable)。
公用方法 PerformDynamicLayout 如果 RibbonComponent 具有像是動態功能表的動態父代 (Parent),而且配置未暫止,請呼叫父控制項的 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 功能表上的自訂控制項,並顯示其名稱。 若要執行這個程式碼範例,您必須先執行下列步驟:

  1. 功能區 (視覺化設計工具) 項目加入至 Office 專案。

  2. 將按鈕加入至 Microsoft Office 按鈕。

  3. 將按鈕的 [(Name)] 屬性設定為 myOfficeMenuButton。

  4. 將 [PositionType] 屬性設定為 [Position] 屬性底下的 AfterOfficeID

  5. 將 [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 命名空間

其他資源

HOW TO:將控制項加入至 Backstage 檢視

功能區物件模型概觀