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);
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.


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");
    var pTableWindow2 = pTableWindow3.ActiveTableWindow as ITableWindow2;
    if (pTableWindow2.Layer != null)
        var pLayer = pTableWindow2.Layer as ILayer;
        var pStandaloneTable = pTableWindow2.StandaloneTable as IStandaloneTable;



| improve this answer | |
  • 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 Nov 13 '15 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 Nov 13 '15 at 16:43
  • Thanks for the reminder! Just done that. Have a great weekend Dan. – Dave Stuart Nov 13 '15 at 16:55
  • I shall do my best. You do the same. – Dan Jurgella Nov 13 '15 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.