Getting an object from an ArcCatalogue selection

801
1
09-18-2011 03:48 PM
PatrickKent-Fahey
New Contributor
Greetings,

I'm trying to get a hold of the object corresponding to the item(s) selected in the ArcCatalogue tree or contents window. However it doesn't seem to work as I would expect.

For example,

        ApplicationCat = (ESRI.ArcGIS.CatalogUI.IGxApplication)ArcCatalog.Application;
        IGxSelection Selected;
        IEnumGxObject SelectedObjects;
        IGxObject SelectedObject;
            
            //get the selection of the contents window
            Selected = ApplicationCat.Selection;
            if (Selected.Count > 0)
            {
                SelectedObjects = Selected.SelectedObjects;
                //loop through the selection
                while ((SelectedObject = SelectedObjects.Next()) != null)
                {
                   IName ObjectType = Dataset.InternalObjectName;
                }


Whenever I use this approach, either from the Selection or SelectedObject properties of IGxApplication the InternalObjectName property of the resulting IGxObject is null (the NameString property is an empty string).

I'm quite new to all this, but it seems like this is a sensible approach. Any ideas would be greatly appreciated.
0 Kudos
1 Reply
AlexanderGray
Occasional Contributor III
From the ArcObjects help on IName.NameString:
"The NameString property is reserved for future use. When implemented, it will return a string representation of the locational component of the name object that may be persisted by applications."
Just because the namestring property is null doesn't mean your name object is null or invalid.  The property is just not implemented.
0 Kudos