[.NET] ArcCatalog 10.1 tree doesn't refresh after adding new custom IGxObject

2097
2
03-23-2013 02:15 AM
IlyaSolovyev
New Contributor II
I am using ArcObjects 10.1 (.NET) to customize ArcCatalog: adding new nodes in catalog tree like in the Esri's example. But when I add new child node to already expanded parent, it doesn't show up in tree. Actually, custom catalog tree node never updates again after being expanded.

Any solutions?
0 Kudos
2 Replies
IlyaSolovyev
New Contributor II
I attached sample project to reproduce described behaviour (it is about "delete node", but result is the same - tree is not refreshed properly):

1. Open solution in Visual Studio 2010
2. Build
3. Register output dll in "bin" directory
4. Run solution
5. In ArcCatalog You will see new tree node called "Parent" with 3 child nodes
[ATTACH=CONFIG]22921[/ATTACH]

6. Select child node and press "Delete". Confirm. Child node is not deleted from tree completely:
[ATTACH=CONFIG]22922[/ATTACH]
0 Kudos
DuncanHornby
MVP Notable Contributor
Ilya,

Here is some VBA code I have used that shows a "brute force" refresh of all folder connections in the Catalog Tree.

Duncan

Public Sub refreshFolders()
    ' Get ArcCatalog Application
    Dim pApp As IGxApplication
    Set pApp = Application


    ' Get the Catalog
    Dim pGXCatalog As IGxCatalog
    Set pGXCatalog = pApp.Catalog


    ' QI Catalog into GXObject
    Dim pGXObject As IGxObject
    Set pGXObject = pGXCatalog


    ' QI GxObject into GxObjectContainer
    Dim pGxObjectContainer As IGxObjectContainer
    Set pGxObjectContainer = pGXObject


    ' Get Gxobjects as an enumerate
    Dim pEnumGxObject As IEnumGxObject
    Set pEnumGxObject = pGxObjectContainer.Children


    ' Cycle through objects until we find the Folder Connections, then break out of loop
    Dim pGxObject2 As IGxObject
    Set pGxObject2 = pEnumGxObject.Next
    Do While Not pGxObject2 Is Nothing
        If TypeOf pGxObject2 Is IGxFolderConnections Then
            Exit Do
        End If
        Set pGxObject2 = pEnumGxObject.Next
    Loop


    ' Re-point GxObjectContainer to folder connection GxObject and refresh all children GxObjects
    Set pGxObjectContainer = pGxObject2
    Set pEnumGxObject = pGxObjectContainer.Children
    Set pGxObject2 = pEnumGxObject.Next
    Do While Not pGxObject2 Is Nothing
        pGxObject2.Refresh
        Set pGxObject2 = pEnumGxObject.Next
    Loop
End Sub
0 Kudos