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. PositionType 屬性設定為 Position 屬性下的 AfterOfficeID

  5. OfficeID 屬性設定為 Position 屬性下的 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物件指派給OfficeMenuOfficeRibbon產生介面的 屬性。 使用此物件可在運行時間將新的控件新增至 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)

適用於