共用方式為


RibbonButton.Image 屬性 (2007 系統)

更新:2007 年 11 月

取得或設定顯示在按鈕上的影像。

命名空間:  Microsoft.Office.Tools.Ribbon
組件:  Microsoft.Office.Tools.Common.v9.0 (在 Microsoft.Office.Tools.Common.v9.0.dll 中)

語法

Public Property Image As Image

Dim instance As RibbonButton
Dim value As Image

value = instance.Image

instance.Image = value
public Image Image { get; set; }

屬性值

型別:System.Drawing.Image

顯示在按鈕上的 Image

備註

建議的影像格式為 PNG,因為 PNG 格式的影像會透過 Alpha 色頻 (Alpha Channel) 支援透明度。

Image 屬性可以識別控制項顯示的影像。這個屬性可以在設計階段或執行階段設定。如果您在執行階段更新這個屬性,則控制項的外觀會更新以反應變更。

如果 Image 屬性已設定,則會忽略 OfficeImageIdImageName 屬性。雖然 Image 屬性較另外兩個屬性提供更多的控制能力,但是每當控制項更新時,它就會將影像物件傳送至 Office 應用程式,因此可能比較慢。

ShowImage 屬性必須為 true,控制項才能顯示影像。當您在設計階段設定 Image 屬性時,Visual Studio Tools for Office 會自動將 ShowImage 屬性設定為 true。如果是在執行階段設定 Image 屬性,您必須在程式碼中,將 ShowImage 屬性設定為 true。

範例

下列範例會設定兩個按鈕的 Image 屬性。若要執行這個程式碼範例,您必須先執行下列步驟:

  1. 將 [功能區 (視覺化設計工具)] 項目加入至 Visual Studio Tools for Office 專案。

  2. 將群組加入至自訂索引標籤。

  3. 將兩個按鈕加入至群組。

  4. 將兩個影像加入至專案資源。如需詳細資訊,請參閱 HOW TO:加入或移除資源

Private Sub LoadImages()
    button1.ShowImage = True
    CustomerButton.ShowImage = True
    Button1.Image = My.Resources.Image1
    CustomerButton.Image = My.Resources.Image2
End Sub
private void LoadImages()
{
    button1.ShowImage = true;
    button2.ShowImage = true;
    button1.Image = Properties.Resources.Image1;
    button2.Image = Properties.Resources.Image2;
}

使用權限

請參閱

參考

RibbonButton 類別

RibbonButton 成員

Microsoft.Office.Tools.Ribbon 命名空間

其他資源

功能區概觀

功能區物件模型概觀