I have an AddIn (C# VS 2010) that depends on the selected items in the Attribute Window (This is the right-click on the Layer Attributes Table Window). When the user hits Start Editing I want to get a handle on the Currently open Attribute Window (or check if it is open) and automatically select the correct Layer. I know how to get the currently selected layer as shown below.
var puid = new UID {Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"};
IEnumLayer penumlayer = _mxDocument.ActiveView.FocusMap.get_Layers(puid, true);
penumlayer.Reset();
featureLayer = penumlayer.Next() as IFeatureLayer;
But I need to check if the Attribute Window is open and then I can auto select the Layer with some other code based on the DataSet Name.
I'm hoping that someone has a code snippet that will help me.
1 Answer 1
The following will get you the layer or standalone table (IStandaloneTable) of the active table window:
var pTableWindow3 = new TableWindow() as ITableWindow3;
if (pTableWindow3.ActiveTableWindow == null)
{
MessageBox.Show("no table open");
}
else
{
var pTableWindow2 = pTableWindow3.ActiveTableWindow as ITableWindow2;
if (pTableWindow2.Layer != null)
{
var pLayer = pTableWindow2.Layer as ILayer;
}
else
{
var pStandaloneTable = pTableWindow2.StandaloneTable as IStandaloneTable;
}
}
-
Thanks Dan! Your code snippet was EXACTLY what I needed. Beautiful to see my code now able to find the Attribute Window and then select the layer. So much easier now for the users! Much appreciated.Dave Stuart– Dave Stuart2015年11月13日 16:31:38 +00:00Commented Nov 13, 2015 at 16:31
-
No problem. Glad it is working for you. And please don't forget to mark the question as answered so it doesn't show up in the unanswered questions list.Dan Jurgella– Dan Jurgella2015年11月13日 16:43:22 +00:00Commented Nov 13, 2015 at 16:43
-
Thanks for the reminder! Just done that. Have a great weekend Dan.Dave Stuart– Dave Stuart2015年11月13日 16:55:48 +00:00Commented Nov 13, 2015 at 16:55
-
I shall do my best. You do the same.Dan Jurgella– Dan Jurgella2015年11月13日 18:21:24 +00:00Commented Nov 13, 2015 at 18:21
ITableWindow3.ActiveTableWindow
? resources.arcgis.com/EN/HELP/ARCOBJECTS-NET/COMPONENTHELP/…