Delen via


RibbonDropDownItem.Tag Property (2007 System)

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

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

Syntax

'Declaration
<BindableAttribute(True)> _
<TypeConverterAttribute(GetType(StringConverter))> _
Public Property Tag As Object
'Usage
Dim instance As RibbonDropDownItem 
Dim value As Object 

value = instance.Tag

instance.Tag = value
[BindableAttribute(true)]
[TypeConverterAttribute(typeof(StringConverter))]
public Object Tag { get; set; }
[BindableAttribute(true)]
[TypeConverterAttribute(typeof(StringConverter))]
public:
property Object^ Tag {
    Object^ get ();
    void set (Object^ value);
}
public function get Tag () : Object 
public function set Tag (value : Object)

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 Visual Studio Tools for Office project.

  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 = New RibbonDropDownItem()
    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 = new RibbonDropDownItem();
    item1.Label = "Class 101";
    item1.Tag = new CourseInfo("101");
    dropDown1.Items.Add(item1);
}

.NET Framework Security

See Also

Reference

RibbonDropDownItem Class

RibbonDropDownItem Members

Microsoft.Office.Tools.Ribbon Namespace

Other Resources

Ribbon Object Model Overview