This document is archived and information here might be outdated.  Recommended version.


ITOCControl2.Buddy Property (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Controls > ESRI ArcGIS Controls > Interfaces > IT > ITOCControl2 Interface > ITOCControl2.Buddy Property
ArcGIS Developer Help

ITOCControl2.Buddy Property

The object whose ActiveView is used to populate the TOCControl.

[Visual Basic .NET]
Public ReadOnly Property Buddy As Object
[C#]
public object Buddy {get;}
[C++]
HRESULT get_Buddy(
void
);

Product Availability

Available with ArcGIS Engine.

Description

The Buddy returns the object implementing ITOCBuddy that was passed to the SetBuddyControl method. The Buddy is responsible for handling the ActiveView, and enables the TOCControl to populate itself with maps, layers and symbols.

The SetBuddyControl method will remove any wrapper object that a development environment has added to the control passed to it. As such, the object passed into the SetBuddyControl method may be different from the object returned by the Buddy.

[C#]
//Determine the Buddy type
if (axTOCControl1.Buddy != null)
{
  //QI for IMapControl3
  if  (axTOCControl1.Buddy is IMapControl3)
  {     
    IMapControl3 mapControl = (IMapControl3) axTOCControl1.Buddy;
  }
  //QI for IPageLayouControl2  
  else if (axTOCControl1.Buddy is IPageLayoutControl2)
  {
    IPageLayoutControl2 pageLayoutControl = (IPageLayoutControl2) axTOCControl1.Buddy;
  }
  //QI for ISceneControl  
  else if (axTOCControl1.Buddy is ISceneControl)
  {
    ISceneControl sceneControl = (ISceneControl) axTOCControl1.Buddy;
  }
  //QI for IGlobeControl 
  else if (axTOCControl1.Buddy is IGlobeControl)
  {
    IGlobeControl globeControl = (IGlobeControl) axTOCControl1.Buddy;
  }
}
[Visual Basic .NET]
'Determine the Buddy type
If Not AxTOCControl1.Buddy Is Nothing Then
  'QI for IMapControl3
  If TypeOf AxTOCControl1.Buddy Is ESRI.ArcGIS.Controls.IMapControl3 Then
    Dim pMapControl As ESRI.ArcGIS.Controls.IMapControl3
    pMapControl = AxTOCControl1.Buddy
  'QI for IPageLayouControl2  
  ElseIf TypeOf AxTOCControl1.Buddy Is ESRI.ArcGIS.Controls.IPageLayoutControl2 Then
    Dim pPageLayoutControl As ESRI.ArcGIS.Controls.IPageLayoutControl2
    pPageLayoutControl = AxTOCControl1.Buddy()
  'QI for ISceneControl  
  ElseIf TypeOf AxTOCControl1.Buddy Is ESRI.ArcGIS.Controls.ISceneControl Then
    Dim pSceneControl As ESRI.ArcGIS.Controls.ISceneControl
    pSceneControl = AxTOCControl1.Buddy
  'QI for IGlobeControl  
  ElseIf TypeOf AxTOCControl1.Buddy Is ESRI.ArcGIS.Controls.IGlobeControl Then
    Dim pGlobeControl As ESRI.ArcGIS.Controls.IGlobeControl
    pGlobeControl = AxTOCControl1.Buddy
  End If
End If

See Also

ITOCControl2 Interface