AnsweredAssumed Answered

Closing Table Window Docking Pane with ITableDocWindowAdmin

Question asked by johnnhansen on Mar 14, 2013
Latest reply on Mar 18, 2013 by geonetadmin
Greetings,

I wish to close the table window docking pane via an addin button. I am using Visual C# 2010 Express. The map user will start with one or more attribute tables open (see two_open_attribute_tables.jpg). I am able to close any/all open attribute tables with this code:

[INDENT]//using ESRI.ArcGIS.ArcMapUI;
//using ESRI.ArcGIS.Framework;
//using ESRI.ArcGIS.esriSystem;
//using ESRI.ArcGIS.Carto;

IMxDocument pMxDoc = ArcMap.Document;
IMap pMap = pMxDoc.FocusMap;
IContentsView pTOC = pMxDoc.CurrentContentsView;
               
IApplication application = ArcMap.Application;
ITableWindow pTableWindow = new TableWindowClass();
pTableWindow.Application = application;
ITableWindow3 pTableWindow3 = pTableWindow as ITableWindow3;

ISet pTableSet = new SetClass();
pTableWindow3.FindOpenTableWindows(out pTableSet);
pTableSet.Reset();
ITableWindow pTableWindowTemp = pTableSet.Next() as ITableWindow;
while (pTableWindowTemp != null)
{
[INDENT]pTableWindowTemp.Show(false);
pTableWindowTemp = pTableSet.Next() as ITableWindow;[/INDENT]}[/INDENT]

This, however, leaves me with an open (and empty) table window pane (see no_open_attribute_windows.JPG). The ITableDocWindowAdmin interface has a close method that should close the window pane (http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/ITableDockWindowAdmin_Interface/000v0000016s000000/), but I have been unsuccessful in passing the pTableWindow or pTableWindow3 to that interface (admittedly, I am in way over my head here). I have also attempted to use the IDockableWindowManager to no avail. Here are some of my (failed) approaches:
[INDENT]
//A)
//ITableDockWindowAdmin pDockWidowAdmin = new TableDockWindowClass();
//pDockWidowAdmin.SetActiveWindow((ITableWindow)pTableWindow3);
//pDockWidowAdmin.Close((ITableWindow)pTableWindow3);

//B)
//ITableDockWindowAdmin pDockWidowAdmin = application as ITableDockWindowAdmin;
//pDockWidowAdmin.SetActiveWindow((ITableWindow)pTableWindow3);
//pDockWidowAdmin.Close((ITableWindow)pTableWindow3);

//C)
//ITableDockWindowAdmin pDockWidowAdmin = new TableDockWindowClass();//application as ITableDockWindowAdmin;
//ITableWindow pTableWindowToClose = new TableWindowClass();//(ITableWindow)pTableWindow3;
//pTableWindowToClose.Application = application;
//pDockWidowAdmin.Close(pTableWindowToClose);[/INDENT]

Any ideas? I have an Esri Incident open, but they have not been able to help.

Thanks!

John

Outcomes