private void button1_Click(object sender, System.EventArgs e)
{
//Get the GraphicsContainer
IGraphicsContainer graphicsContainer = axPageLayoutControl1.GraphicsContainer;

//Get the MapFrame
IMapFrame mapFrame = (IMapFrame) graphicsContainer.FindFrame(axPageLayoutControl1.ActiveView.FocusMap);
if (mapFrame == null) return;

//Create a legend
UID uID = new UIDClass();
uID.Value = "esriCarto.Legend";

//Create a MapSurroundFrame from the MapFrame
IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null);
if (mapSurroundFrame == null) return;
if (mapSurroundFrame.MapSurround == null) return;
//Set the name
mapSurroundFrame.MapSurround.Name = "Legend";

//Envelope for the legend
IEnvelope envelope = new EnvelopeClass();
envelope.PutCoords(1, 1, 3.4, 2.4);

//Set the geometry of the MapSurroundFrame
IElement element = (IElement) mapSurroundFrame;
element.Geometry = envelope;

//Add the legend to the PageLayout
axPageLayoutControl1.AddElement(element, Type.Missing, Type.Missing, "Legend", 0);

//Refresh the PageLayoutControl
axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

//disable/enable buttons
cmdDraw.Enabled = false;
cmdDelete.Enabled = true;
cmdChangeArea.Enabled = true;
cmdChangeLine.Enabled = true;
}

private void button2_Click(object sender, System.EventArgs e)
{
//Find the legend
IElement element = axPageLayoutControl1.FindElementByName("Legend", 1);

if(element != null)
{
//Delete the legend
IGraphicsContainer graphicsContainer = axPageLayoutControl1.GraphicsContainer;
graphicsContainer.DeleteElement(element);
//Refresh the display
axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

//enable/disable buttons
cmdDraw.Enabled = true;
cmdDelete.Enabled = false;
cmdChangeArea.Enabled = false;
cmdChangeLine.Enabled = false;
}
}

增加图例 Legend和删除图例的更多相关文章

  1. highcharts图表的图例legend怎么改变显示位置

    一.将图例Legend放于图表右侧1.设置chart的marginRight属性值:chart: { marginRight: 120}2.设置legend图例属性值如下 legend: { alig ...

  2. highcharts图表的图例legend

    一.将图例Legend放于图表右侧1.设置chart的marginRight属性值:chart: { marginRight: 120}2.设置legend图例属性值如下 legend: { alig ...

  3. python 2: 解决python中的plot函数的图例legend不能显示中文问题

     问题: 图像标题.横纵坐标轴的标签都能显示中文名字,但是图例就是不能显示中文,怎么解决呢?  解决: plt.figure() plt.title(u'训练性能', fontproperties=f ...

  4. echart 饼图图例legend支持滑动

    ps: 以下针对option操作 文章目录 图例过多加上滚动条图例形状图例自定义显示图例过多加上滚动条 legend:{ top:'50', bottom:'50', type:'scroll',} ...

  5. fusioncharts图例(legend)属性

    图例用来在多系列图和混合图中将图形和对应的系列名称联系起来.      从v3.2开始,每个系列的名称前面会展示对应的icon图标,这些图标具有交互作用,用户可以通过点击这些图标来显示或者隐藏对应的数 ...

  6. ASP.NET MVC3 实例(六) 增加、修改和删除操作(二)

    http://www.jquery001.com/asp.net-mvc3-instance-add-update-delete2.html 上篇我们在 ASP.NET MVC3 中实现了添加操作,由 ...

  7. ASP.NET 操作Cookie详解 增加,修改,删除

    ASP.NET 操作Cookie详解 增加,修改,删除 Cookie,有时也用其复数形式Cookies,指某些网站为了辨别用户身份而储存在用户本地终端上的数据(通常经过加密).定义于RFC2109.它 ...

  8. MBR分区操作-增加、扩展、删除

    MBR分区操作-增加.扩展.删除 GPT分区参考 http://www.blogjava.net/haha1903/archive/2011/12/21/366942.html l  fdisk 显示 ...

  9. 在linux中,如何增加、修改、删除、暂停和冻结用户名

    在Linux中,如何增加.修改.删除.暂停和冻结用户名 在操作增加.修改和删除用户名前,先认识linux中两个最重要的文件,它们就是账号管理最重要文件“/etc/passwd”与“etc/shadow ...

随机推荐

  1. Process Explore & Windbg

    遇到点内存泄漏.句柄泄漏,应该是家常便饭了.这次就是,程序运行内存一点点增加,句柄也是只增不减,个数竟然可以达到几十万,真是瞪大了我的双眼. 借此机会,学习下相关工具~ Process Explore ...

  2. Python3模块: hashlib

    简介: 用于加密相关的操作,代替了md5模块和sha模块,主要提供SHA1,SHA224,SHA256,SHA384,SHA512,MD5算法. 在python3中已经废弃了md5和sha模块,简单说 ...

  3. git常用的命令你知道有哪些?

    1.git与svn的区别 1,git是目前世界上最先进的分布式版本控制系统,他没有中央服务器,每个人的电脑就是一个完整的版本库,这样,工作的时候不需要联网 2,svn是集中式版本控制系统,版本库是集中 ...

  4. Centos下用yum命令按照jdk

    一.查看是否已经安装了JDK #查看本机是否已经安装了jdk $ sudo yum list installed | grep java java--openjdk.x86_64 :.el7_6 @u ...

  5. 【xsy1058】 单词 乱搞

    题目大意:给你$n$个长度为$m$的字符串,字符集仅为{x,y,z}三个字符,定义两个字符串$(s_i,s_j)$的相似度为$\sum_{k=1}^{m} [s_i[k]==s_j[k]]$. 从$0 ...

  6. Oracle 常见字符操作

    一.拼接 1.使用 || 来实现 SELECT '你'||'好!' title FROM dual; 2.使用concat (不支持多个字符串的拼接,但是可以嵌套调用) SELECT concat(' ...

  7. 给button添加UAC的小盾牌图标

    Sample Code: public partial class Form1 : Form { public Form1() { InitializeComponent(); } private v ...

  8. 【树】Binary Tree Zigzag Level Order Traversal

    题目: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from lef ...

  9. C/C++ -- Gui编程 -- Qt库的使用 -- 使用图片与动画

    QWidget工程 #include "mywidget.h" #include "ui_mywidget.h" #include <QLabel> ...

  10. OpenGL10-骨骼动画原理篇(3)-Shader版本代码已经上传

    视频教程请关注 http://edu.csdn.net/lecturer/lecturer_detail?lecturer_id=440 接上一个例程OpenGL10-骨骼动画原理篇(2),对骨骼动画 ...