在ArcEngine开发过程中,当点击添加表时,如下图所示,即使可以选中表,但却不会显示在TocControl控件上,TocControl控件只显示图层,为了可以添加独立表,需自己创建显示表的控件,如TreeView,
当我们点击添加表时,实际上已将表添加到MapControl控件中了,只是无法展示而已,只需添加如下代码,即可在TreeView中呈现,(这是的TreeView控件为WPF控件,非WinForm)
IStandaloneTableCollection iTableCollection = m_MapCtrl.Map as IStandaloneTableCollection;
for (int i = 0; i < iTableCollection.StandaloneTableCount; i++)
{
IStandaloneTable table1 = iTableCollection.get_StandaloneTable(i);
TreeViewItem mtrnode = new TreeViewItem();
mtrnode.Header = table1.Name;
treeTable.Items.Add(mtrnode);
}