[GIS] Refresh Currently Open ArcMap Attribute Table using ArcObjects

arcgis-10.0arcmaparcobjectsattribute-tablevb.net

I have written an ArcMap Addin (ArcMap 10.0) that allows a user to perform a join between an in-memory table and a feature class (feature layer) added to the TOC. I want the attribute table of the feature layer to automatically refresh after the join occurs if the user happens to have the attribute table visible when performing the join. This way the fields added to the table via the join will be visible to the user without having to close and reopen the Attribute Table.

The following function is what I have tried to refresh the Attribute Table, but it does not actually refresh the display.

Private Sub RefreshAttributeTable()
    Try
        Dim tableWindow As ITableWindow3 = New TableWindow
        tableWindow.ActiveTableWindow.Refresh()

        My.ArcMap.Document.ActiveView.Refresh()
    Catch ex As Exception

        Debug.WriteLine(String.Format("{0}; {1}", ex.Message, ex.StackTrace))

    End Try
End Sub

Can anyone help with this?

Best Answer

Your code creates a new table window obj but does not set it to any existing table. You should pass a reference to the ITableWindow3 obj that you want to refresh into your sub. If you don't have the obj reference already then use ITableWindow3.FindOpenTableWindows method to get an ISet obj that you can then loop to find the desired window. I believe the tableWindow.ActiveTableWindow.Refresh() call will work once you have tableWindow set to an existing obj.

Related Question