RibbonDropDownItem.Tag 屬性
取得或設定與這個 RibbonDropDownItem 關聯的應用程式特定資料。
命名空間: Microsoft.Office.Tools.Ribbon
組件: Microsoft.Office.Tools.Common (在 Microsoft.Office.Tools.Common.dll 中)
語法
'宣告
<BindableAttribute(True)> _
<TypeConverterAttribute> _
Property Tag As Object
Get
Set
[BindableAttribute(true)]
[TypeConverterAttribute]
Object Tag { get; set; }
屬性值
型別:System.Object
物件,表示與這個 RibbonDropDownItem 關聯的應用程式特定資料。
備註
衍生自 System.Object 類別的任何類型都可以指定至這個屬性。 不過,如果您在 Visual Studio 的 [屬性] 視窗中設定 Tag 屬性,則只能指派文字。
Tag 屬性一般是用來存放與項目密切相關的資料。
範例
下列範例會設定下拉式方塊中 RibbonDropDownItem 的 Tag 屬性。
若要執行這個程式碼範例,您必須先執行下列步驟:
將 [功能區 (視覺化設計工具)] 項目加入至在 Visual Studio 中使用 Office 開發工具建立的專案。
將下拉式方塊加入至預設群組 Group1。
Public Class CourseInfo
Private ID As String
Public Sub New(ByVal _courseID As String)
ID = _courseID
End Sub
End Class
Private Sub AddDropDownTag()
Dim item1 As RibbonDropDownItem = Me.Factory.CreateRibbonDropDownItem()
item1.Label = "Class 101"
item1.Tag = New CourseInfo("101")
DropDown1.Items.Add(item1)
End Sub
public class CourseInfo
{
private string ID;
public CourseInfo(string _courseID)
{
ID = _courseID;
}
}
private void AddDropDownTag()
{
RibbonDropDownItem item1 = this.Factory.CreateRibbonDropDownItem();
item1.Label = "Class 101";
item1.Tag = new CourseInfo("101");
dropDown1.Items.Add(item1);
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.Office.Tools.Ribbon 命名空間