ITableSelection in a map document

480
2
12-02-2013 07:30 AM
JohnStephens
Occasional Contributor
I have an add-in tool for arcmap that is basically a customized selection tool.  I have it working just fine for feature class selections, but I cannot seem to get it to show the Table selections in the map document.  This is the method I have for the table selections:

private void SelectTableFeaturesByAttributeQuery(IStandaloneTable standAloneTable, string whereClause, bool addToSelection)
{
   // a selection cannot be done if any of these are empty
   if (activeView == null || standAloneTable == null || whereClause == null) return;

   ITableSelection tableSelection = (ITableSelection)standAloneTable;

   // Set up the query
   IQueryFilter queryFilter = new QueryFilterClass();
   queryFilter.WhereClause = whereClause;

   // Perform the selection
   try
   {
      if (addToSelection)
         tableSelection.SelectRows(queryFilter, esriSelectionResultEnum.esriSelectionResultAdd, false);
      else
         tableSelection.SelectRows(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
   }
   catch (Exception ex)
   {
      // taken out, not relevant
   }

   tableSelection.SelectionChanged();
}


When I run this on a table it runs without an error, but does not show the selection in the tables once it is complete.  What am I missing?
0 Kudos
2 Replies
LeoDonahue
Occasional Contributor III
can you try passing a null where clause to see if it selects all records in the stand alone table?
0 Kudos
JohnStephens
Occasional Contributor
A null queryfilter did work.  So, I went ahead and checked the format of my where clauses and magically it started working.  Weird.
0 Kudos