0

I have to develop an extension in C# for ArcMap 10.2 and I need to show information from a datatable in an a table window.

I can show the table without problems, but I have a problem I can´t resolve.

If I show table with one record, for example, and then I want to show the information of another table, even if the new table has several records, the table window show only one.

This is the piece of code I use:

if (pTable != null) { IStandaloneTable pStandAloneTable = new StandaloneTableClass();
pStandAloneTable.Table = pTable;
pTWindow.StandaloneTable = pStandAloneTable;
pTWindow.Application = Connector.ConnectorExtension.Aplicacion;

if(!pTWindow.IsVisible) pTWindow.Show(true);

if (pTable != null)
{
 IStandaloneTable pStandAloneTable = new StandaloneTableClass();
 pStandAloneTable.Table = pTable;
 pTWindow.StandaloneTable = pStandAloneTable;
 pTWindow.Application = Connector.ConnectorExtension.Aplicacion;

 if(!pTWindow.IsVisible)
  pTWindow.Show(true);


 System.Diagnostics.Debug.Print("Table: " + pTWindow.StandaloneTable.Name);
 System.Diagnostics.Debug.Print("Records: + pTWindow.StandaloneTable.Table.RowCount(null).ToString());

pTWindow.StandaloneTable.Table.RowCount has the correct number of records in the table but the table window doesn´t show them

1

The following VBA code will open up all Standalone tables in the current map document, if this what you were trying to achieve.

Public Sub DisplayTables()
    ' Opens up all standalone tables in the map document in the TableWindow

    ' Get MXD
    Dim pMXDocument As IMxDocument
    Set pMXDocument = ThisDocument

    ' Get Map
    Dim pMap As IMap
    Set pMap = pMXDocument.FocusMap

    ' Get table collection
    Dim pStandaloneTableCollection As IStandaloneTableCollection
    Set pStandaloneTableCollection = pMap

    ' Create a TableWindow so we can find tables
    Dim pTableWindow As ITableWindow3
    Set pTableWindow = New TableWindow
    Set pTableWindow.Application = Application

    ' Main loop
    Dim pTW As ITableWindow3
    Dim pST As IStandaloneTable
    Dim pTWnew As ITableWindow3
    For i = 0 To pStandaloneTableCollection.StandaloneTableCount - 1
        Set pST = pStandaloneTableCollection.StandaloneTable(i)
        Set pTW = pTableWindow.FindViaStandaloneTable(pST)
        If pTW Is Nothing Then
            ' If nothing is returned then Table is not open, so create a TableWindow and show it
            ' If pTW is returned then it must be open
            Set pTWnew = New TableWindow
            Set pTWnew.Application = Application
            Set pTWnew.StandaloneTable = pST
            pTWnew.Show True
        End If
    Next i
End Sub
  • Despite I can´t see all records in the table window, if I open the Select by Attributes wizard I can see all of them. – vaparicio Jun 12 '14 at 13:53
  • How many rows are in your the table? I think ArcMap typically shows the first few thousand. If you have hundreds of thousands then you need to click on the go to end row button and then ArcMap loads them. – Hornbydd Jun 12 '14 at 16:01
  • The first table I show has one record and the second one has two records. – vaparicio Jun 13 '14 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.