本文為機器翻譯文章。如需檢視英文版,請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上,即可在快顯視窗顯示英文原文。
譯文
原文

RibbonMenu.OfficeImageId 屬性

 

取得或設定要顯示在功能表上的影像 (如果想要使用內建的 Microsoft Office 圖示)。

命名空間:   Microsoft.Office.Tools.Ribbon
組件:  Microsoft.Office.Tools.Common (於 Microsoft.Office.Tools.Common.dll)

string OfficeImageId { get; set; }

屬性值

Type: System.String

作為這個功能表圖示之內建 Microsoft Office 圖示的識別碼。

The P:Microsoft.Office.Tools.Ribbon.RibbonMenu.OfficeImageId property identifies an Office icon that is displayed by the control. The property value is a string that identifies the imageMso value of the selected icon. This property can be set at design time or at run time. If you update this property at run time, the control's appearance is updated to reflect the change.

For a list of imageMso values, see the Microsoft Download Center page Office 2010 Add-In: Icons Galleryhttp://go.microsoft.com/fwlink/?LinkID=220760.

This property is ignored if the P:Microsoft.Office.Tools.Ribbon.RibbonMenu.Image property is set. Images identified by the P:Microsoft.Office.Tools.Ribbon.RibbonMenu.OfficeImageId property can be loaded slightly faster than images identified by the P:Microsoft.Office.Tools.Ribbon.RibbonMenu.Image property, because the images are cached in the Office application.

The P:Microsoft.Office.Tools.Ribbon.RibbonMenu.ShowImage property must be true for the control to display the image. When you set the P:Microsoft.Office.Tools.Ribbon.RibbonMenu.OfficeImageId property at design time, Visual Studio automatically sets the P:Microsoft.Office.Tools.Ribbon.RibbonMenu.ShowImage property to true. If you set the P:Microsoft.Office.Tools.Ribbon.RibbonMenu.OfficeImageId property at run time, you must set the P:Microsoft.Office.Tools.Ribbon.RibbonMenu.ShowImage property to true in your code.

The following example assigns a Microsoft Office icon to a menu.

To run this code example, you must first perform the following steps:

  1. Add a Ribbon (Visual Designer) item to an 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 void SetMenuImage()
{
    menu1.OfficeImageId = "HighImportance";
    menu1.ShowImage = true;
}
回到頁首
顯示: