Freigeben über


RibbonDropDownItem.Tag Property

Definition

Gets or sets application-specific data that is associated with this RibbonDropDownItem.

public:
 property System::Object ^ Tag { System::Object ^ get(); void set(System::Object ^ value); };
[System.ComponentModel.Bindable(true)]
[System.ComponentModel.Localizable(false)]
[System.ComponentModel.TypeConverter]
public object Tag { get; set; }
[<System.ComponentModel.Bindable(true)>]
[<System.ComponentModel.Localizable(false)>]
[<System.ComponentModel.TypeConverter>]
member this.Tag : obj with get, set
Public Property Tag As Object

Property Value

An object that represents application-specific data that is associated with this RibbonDropDownItem.

Attributes

Examples

The following example sets the Tag property of a RibbonDropDownItem in a drop down box.

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

  1. Add a Ribbon (Visual Designer) item to a project created by using Office development tools in Visual Studio.

  2. Add a drop down box to the default group Group1.

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);
}
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

Remarks

Any type derived from the System.Object class can be assigned to this property. However, if you set the Tag property in the Visual Studio Properties window, you can only assign text.

A common use for the Tag property is to store data that is closely associated with the item.

Applies to