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

RibbonComboBox.OfficeImageId 屬性

 

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

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

string OfficeImageId { get; set; }

屬性值

Type: System.String

內建的 Microsoft Office 圖示 (作為此控制項的圖示) 的 ID。

The P:Microsoft.Office.Tools.Ribbon.RibbonComboBox.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.RibbonComboBox.Image property is set. Images identified by the P:Microsoft.Office.Tools.Ribbon.RibbonComboBox.OfficeImageId property can be loaded slightly faster than images identified by the P:Microsoft.Office.Tools.Ribbon.RibbonComboBox.Image property, because the images are cached in the Office application.

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

The following example assigns a Microsoft Office filter icon to a combo box.

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 combo box to the group.

private void SetComboBoxImage()
{
    comboBox1.OfficeImageId = "FilterToggleFilter";
    comboBox1.ShowImage = true;
}
回到頁首
顯示: