Share via


RibbonDropDownItem.Tag Property

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

Namespace:  Microsoft.Office.Tools.Ribbon
Assembly:  Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)

Syntax

'Declaration
<BindableAttribute(True)> _
<TypeConverterAttribute> _
Property Tag As Object
[BindableAttribute(true)]
[TypeConverterAttribute]
Object Tag { get; set; }

Property Value

Type: System.Object
An object that represents application-specific data that is associated with this RibbonDropDownItem.

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.

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 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 Security

See Also

Reference

RibbonDropDownItem Interface

Microsoft.Office.Tools.Ribbon Namespace

Other Resources

Ribbon Object Model Overview