This document is archived and information here might be outdated. Recommended version. |
A property to associate data with an item.
[Visual Basic .NET]
Public Property CustomProperty As Object
[C#]
public object CustomProperty {get; set;}
[C++]
HRESULT get_CustomProperty(
Variant* pVal
);
[C++]
HRESULT put_CustomProperty(
VARIANT pVal
);
[C++] Parameters pVal [out, retval]
pVal is a parameter of type VARIANT* pVal [in]
pVal is a parameter of type VARIANT
Use the CustomProperty to associate any useful data with the ToolbarItem. This is similar to a 'Tag' property, and can be use to store strings, numbers and objects.
//To set a custom property
IToolbarItem toolbarItem = axToolbarControl1.GetItem(0);
toolbarItem.CustomProperty = layer;
//To get a custom property
IToolbarItem toolbarItem = axToolbarControl1.GetItem(0);
if (toolbarItem.CustomProperty is ILayer)
{
ILayer layer = (ILayer) toolbarItem.CustomProperty;
System.Windows.Forms.MessageBox.Show(layer.Name);
}
'To set a custom property
Dim pToolbarItem As IToolbarItem
pToolbarItem = AxToolbarControl1.GetItem(0)
pToolbarItem.CustomProperty = pLayer
'To get a custom property
Dim pToolbarItem As IToolbarItem
pToolbarItem = AxToolbarControl1.GetItem(0)
If TypeOf pToolbarItem.CustomProperty Is ILayer Then
'Dim pLayer As ILayer
pLayer = pToolbarItem.CustomProperty
System.Windows.Forms.MessageBox.Show(pLayer.Name)
End If