AE开发,根据表名和工作空间名称获取独立表

要获取数据库(如.mdb,.gdb)中的独立表,需用到IStandaloneTable接口与ITable接口,代码如下

        public IStandaloneTable GetTableByName(string tablename)
        {
            if (m_CurrentWorkspace!=null)
            {               
                IFeatureWorkspace pFeatureWorkspace = m_CurrentWorkspace as IFeatureWorkspace;
                if (m_CurrentWorkspace == null | pFeatureWorkspace == null)
                {
                    return null;
                }
                if ((m_CurrentWorkspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTTable, tablename))
                {
                    IStandaloneTable ist = new StandaloneTable();
                    ITable itabl = pFeatureWorkspace.OpenTable(tablename);
                    ist.Table = itabl;
                    return ist;
                }
                return null;
            }
            return null;
        }

再通过TreeView控件(WPF)展示,代码如下:

               
                IStandaloneTable pfcT = GetTableByName(featureclassname);
                IStandaloneTableCollection iTableCollection = m_MapCtrl.Map as IStandaloneTableCollection;
                iTableCollection.AddStandaloneTable(pfcT);
                TreeViewItem mtrnode = new TreeViewItem();
                mtrnode.Header = featureclassname;
                treeTable.Items.Add(mtrnode);
                treeTable.Items.Refresh();

注意:本文选择IStandaloneTable接口而非ITable,因为当数据源缺失时,使用ITable是获取不了表的,从IStandaloneTable中的描述“Provides access to members that control a standalone table.”也可得知该接口可获取独立表。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值