IGraphicsContain 删除元素

本文详细介绍了如何在AxMapControl中通过遍历和交互方式获取并删除指定的Element,包括直接通过Name指定Element的方法。同时,强调了在创建Element时为其指定名字的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

刚想实现删除axMapControl 中指定的元素。实现该功能首先得获取欲删除的Element。

下面代码为遍历方式获取其中的Element

   
IGraphicsContainer pGrappic=axMapControl1.Actiview as IGrapicsContainer
 IElement pElement = pGraphic.Next();

IGraphicsContainer 还提供了交互式的获取Elments,其中包括以point的选的 pGraphic.LocateElements和以Envelope 选的pGraphic.LocateElementsByEnvelope。

此为第一种方式。即需人际交互式。

第二种方式为: 在创建Element的时候指定Element的名字,删除的时候删除指定的名称的Element的

 IElement pElement = pGraphic.Next();

            while (pElement != null)
            {
                IElementProperties pd = pElement as IElementProperties;
                if (pd.Name == name)
                {
                    pGraphic.DeleteElement(pElement);
                   
                }
                pElement = pGraphic.Next();
            }

给Element 指定名字的时候也是得QI到IElementProperties 接口

IElementProperties pEl=pElement as IElementProperties.
pEl.Name="****";

 

 

转载于:https://www.cnblogs.com/myyouthlife/archive/2012/07/15/2592150.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值