This document is archived and information here might be outdated. Recommended version. |
ArcObjects namespaces > Controls > ESRI ArcGIS Controls > Interfaces > IT > ITOCControl2 Interface > ITOCControl2.SelectItem Method (ArcObjects .NET 10.4 SDK) |
Sets the selected item in the TOCControl.
[Visual Basic .NET] Public Sub SelectItem ( _ ByVal Unk As Object, _ [ByVal Data As Object] _ )
[C#] public void SelectItem ( object Unk, object Data );
Optional Values
[C++]
HRESULT SelectItem(
LPUNKNOWN Unk,
VARIANT Data
);
[C++]
Parameters Unk [in] Unk is a parameter of type LPUNKNOWN Data [optional] Data is a parameter of type VARIANT
To indicate this parameter is undefined pass in a VARIANT with type VT_ERROR and scode value of DISP_E_PARAMNOTFOUND.
Selects the specified item in the TOCControl. The selected item will appear blue when the TOCControl has keyboard focus and grey when the TOCControl does not have keyboard focus.
Unk specifies an IMap object, and ILayer object or and ILegendGroup object.
Data specifies a long indicating the index of the legend class within the legend group. Use this index in conjunction with the legend group to obtain a particular legend class.
To select an ILegendGroup::Heading either just pass an ILegendGroup object or pass an ILegendGroup object with an index of -1. To select a legend class within the LegendGroup pass an ILegendGroup object with a valid index.
1055 800a041f: A valid object is required for this property
1082 800a043a: The specified object could not be found
//Selecting the focus map
axTOCControl1.SelectItem(axTOCControl1.ActiveView.FocusMap);//Selecting a layer in the focus map
axTOCControl1.SelectItem(axTOCControl1.ActiveView.FocusMap.get_Layer(0));//To select an item within a LegendGroup
ILayer layer=axTOCControl1.ActiveView.FocusMap.get_Layer(0); ILegendInfo legendInfo=(ILegendInfo) layer; ILegendGroup legendGroup=legendInfo.get_LegendGroup(0);//Select a heading
axTOCControl1.SelectItem(legendGroup);//Select a legend class
axTOCControl1.SelectItem(legendGroup, 2);
'Selecting the focus map
AxTOCControl1.SelectItem(AxTOCControl1.ActiveView.FocusMap)'Selecting a layer in the focus map
AxTOCControl1.SelectItem(AxTOCControl1.ActiveView.FocusMap.Layer(0))'To select an item within a LegendGroup
Dim
playerAs
ILayer player=AxTOCControl1.ActiveView.FocusMap.Layer(0)Dim
legendInfoAs
ILegendInfo legendInfo=playerDim
pLegendGroupAs
ILegendGroup pLegendGroup=legendInfo.LegendGroup(0)'Select a heading
AxTOCControl1.SelectItem(pLegendGroup)'Select a legend class
AxTOCControl1.SelectItem(pLegendGroup, 2)