RibbonComponent.Tag Property (2007 System)
Gets or sets application-specific data that is associated with this RibbonComponent.
Namespace: Microsoft.Office.Tools.Ribbon
Assembly: Microsoft.Office.Tools.Common.v9.0 (in Microsoft.Office.Tools.Common.v9.0.dll)
Syntax
'Declaration
Public Property Tag As Object
'Usage
Dim instance As RibbonComponent
Dim value As Object
value = instance.Tag
instance.Tag = value
public Object Tag { get; set; }
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 System.Object that represents application-specific data that is associated with this RibbonComponent.
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 control. For example, if you have a button that displays information about a customer, you might store a System.Data.DataSet that contains the customer's order history in the button's Tag property so the data can be accessed quickly.
Examples
The following example demonstrates how to set an array of Employee objects to the Tag property of a group and how to retrieve the value of the Tag property. This example requires that you have defined a class called Employee that exposes the String property ID and that you have defined a GetEmployees method that returns an array of Employee objects.
To run this code example, you must first perform the following steps:
Add a Ribbon (Visual Designer) item to a Visual Studio Tools for Office project.
Add a button to the default group Group1.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles Button1.Click
' Set the group's Tag property
Group1.Tag = GetEmployees()
' Show all customers by retrieving them from the group's Tag property
For Each emp As Employee In CType(Group1.Tag, Employee())
System.Windows.Forms.MessageBox.Show(emp.ID)
Next
End Sub
private void button1_Click(object sender, RibbonControlEventArgs e)
{
// Set the group's Tag property
group1.Tag = GetEmployees();
// Show all customers by retrieving them from the group's Tag property
foreach (Employee emp in (Employee[])group1.Tag)
{
System.Windows.Forms.MessageBox.Show(emp.ID);
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.