Closing Table Window Docking Pane with ITableDocWindowAdmin

1819
1
Jump to solution
03-14-2013 07:49 AM
JohnHansen
New Contributor III
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_In...), 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
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Original User: johnnhansen

Solution, care of Sharvari with Esri Support:

[INDENT]
//using System;
//using System.Collections.Generic;
//using System.Text;
//using System.IO;
//using ESRI.ArcGIS.Framework;
//using ESRI.ArcGIS.esriSystem;

IDockableWindowManager pDocWinMgr;
IDockableWindow pTOC;
pDocWinMgr =(IDockableWindowManager) ArcMap.Application;
UID uid = new UIDClass();
uid.Value = "{2B740D8F-442C-4975-BCE7-59D9949DAD9E}";
pTOC = pDocWinMgr.GetDockableWindow(uid);
pTOC.Show(false);
ArcMap.Application.CurrentTool = null;[/INDENT]

View solution in original post

0 Kudos
1 Reply
by Anonymous User
Not applicable
Original User: johnnhansen

Solution, care of Sharvari with Esri Support:

[INDENT]
//using System;
//using System.Collections.Generic;
//using System.Text;
//using System.IO;
//using ESRI.ArcGIS.Framework;
//using ESRI.ArcGIS.esriSystem;

IDockableWindowManager pDocWinMgr;
IDockableWindow pTOC;
pDocWinMgr =(IDockableWindowManager) ArcMap.Application;
UID uid = new UIDClass();
uid.Value = "{2B740D8F-442C-4975-BCE7-59D9949DAD9E}";
pTOC = pDocWinMgr.GetDockableWindow(uid);
pTOC.Show(false);
ArcMap.Application.CurrentTool = null;[/INDENT]
0 Kudos