Hello! I am trying to remove a specified standalone table from the Contents pane. Here is the code I have so far:
try
{
var mapView = MapView.Active;
if (mapView != null)
{
var map = mapView.Map;
if (map != null)
{
foreach (StandaloneTable table in map.StandaloneTables)
{
if (table.Name.Contains("K Factors"))
map.RemoveStandaloneTable(table);
}
}
}
}
catch (Exception ex)
{
}There may be multiple tables whose name contains "K Factors" and that's ok -- I would like them all removed.
I noticed that map.StandaloneTables is a ReadOnlyObservableCollection and I'm not sure if this has to do with the exceptions that I'm getting.
The exception says either, {"Class not registeredClass not registered"} or {"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"}
Any help would be appreciated.