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


Retrieve Objects From Component Category Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Retrieve Objects From Component Category Snippet

Get all the objects for a specified component category GUID.

[C#]
/// <summary>
/// Get all the objects for a specified component category GUID.
/// </summary>
/// <param name="string_ComponetCategoryGUID">A String that is the component category GUID in the registry format. Example: "{3eea2caf-a730-11d2-af6d-080009ec734b}" is for the ESRI GX Tab Views.</param>
/// <remarks>Note: You can use the ESRI Component Category Manager (C:\Program Files\ArcGIS\Bin\categories.exe) to find the names of the component categories.
/// You can then use the Windows registry editor (C:\WINDOWS\regedit.exe) to search for the ESRI category names and obtain the GUID associated with it.
/// </remarks>
public void RetrieveObjectsFromComponentCategory(System.String string_ComponetCategoryGUID)
{

    // Set up GUID object for the desired component category
    ESRI.ArcGIS.esriSystem.IUID uid=new ESRI.ArcGIS.esriSystem.UIDClass();
    uid.Value=string_ComponetCategoryGUID;

    // Set up the category factory.
    ESRI.ArcGIS.esriSystem.ICategoryFactory categoryFactory=new ESRI.ArcGIS.esriSystem.CategoryFactoryClass();
    categoryFactory.CategoryID=(ESRI.ArcGIS.esriSystem.UID)uid;

    // Go through each member of the category, and do something with it as needed
    object object_Category=categoryFactory.CreateNext();
    while (object_Category != null)
    {

        object_Category=categoryFactory.CreateNext();

        // TODO: process the object retrieved
        // ...

    }
}

[Visual Basic .NET]
''' <summary>
''' Get all the objects for a specified component category GUID.
''' </summary>
''' <param name="string_ComponetCategoryGUID">A String that is the component category GUID in the registry format. Example: "{3eea2caf-a730-11d2-af6d-080009ec734b}" is for the ESRI GX Tab Views.</param>
''' <remarks>Note: You can use the ESRI Component Category Manager (C:\Program Files\ArcGIS\Bin\categories.exe) to find the names of the component categories.
''' You can then use the Windows registry editor (C:\WINDOWS\regedit.exe) to search for the ESRI category names and obtain the GUID associated with it.
''' </remarks>
Public Sub RetrieveObjectsFromComponentCategory(ByVal string_ComponetCategoryGUID As System.String)

  ' Set up GUID object for the desired component category
  Dim uid As ESRI.ArcGIS.esriSystem.IUID=New ESRI.ArcGIS.esriSystem.UIDClass
  uid.Value=string_ComponetCategoryGUID

  ' Set up the category factory.
  Dim categoryFactory As ESRI.ArcGIS.esriSystem.ICategoryFactory=New ESRI.ArcGIS.esriSystem.CategoryFactoryClass
  categoryFactory.CategoryID=CType(uid, ESRI.ArcGIS.esriSystem.UID)

  ' Go through each member of the category, and do something with it as needed
  Dim object_Category As System.Object=categoryFactory.CreateNext
  Do While Not object_Category Is Nothing

    object_Category=categoryFactory.CreateNext

    ' TODO: process the object retrieved
    ' ...

  Loop

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.System