C# ArcEngine TOCControl上实现右键
来源:互联网 发布:java httpclient请求 编辑:程序博客网 时间:2024/06/06 03:02
TOCControl控件使用的是用伙伴控件中的数据地图,它控制图层是否在伙伴控件空显示以及和伙伴控件在符号上保持一致,TOCControl为用户提供了一个交互式的环境,如果TOCControl控件的伙伴控件是MapControl控件,当我们将TOCControl控件中图层删掉是,MapControl控件中相应的图层也会被删掉。
显示属性表的信息
而ArcGIS Engine提供的TOCControl控件几乎没有提供,那么这些都是需要自己开发的,在这里我做一个显示属性表的功能。
分析:要显示某一个图层的属性表,首先要将这个图层选中,然后在另外一个Form中将选中的这个图层的属性信息进行显示。
添加一个上下文菜单,添加一个新的Form窗体,在这个新的窗体上添加GridView控件,并在TOCControl控件的OnMouseDown事件下添加如下代码(pGlobalFeatureLayer是我定义的一个全局变量):
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
{
if (axMapControl1.LayerCount > 0)
{
esriTOCControlItem pItem = new esriTOCControlItem();
pGlobalFeatureLayer = new FeatureLayerClass();
IBasicMap pBasicMap = new MapClass();
object pOther = new object();
object pIndex = new object();
axTOCControl1.HitTest(e.x, e.y, ref pItem, ref pBasicMap, ref pGlobalFeatureLayer, ref pOther, ref pIndex);
}
if (e.button == 2)
{
context.Show(axTOCControl1, e.x, e.y);
}
}
在上下文菜单的打开属性表的Click事件中添加如下代码:
private void 打开属性表ToolStripMenuItem_Click(object sender, EventArgs e)
{
FormTable Ft = new FormTable(pGlobalFeatureLayer as IFeatureLayer);
Ft.Show();
}
在新的窗体中添加一个将属性表显示到GridView控件中的函数,如下:
public void Itable2Dtable()
{
IFields pFields;
pFields = pFeatureLayer.FeatureClass.Fields;
dtGridView.ColumnCount = pFields.FieldCount;
for (int i = 0; i < pFields.FieldCount;i++ )
{
string fldName = pFields.get_Field(i).Name;
dtGridView.Columns[i].Name = fldName;
dtGridView.Columns[i].ValueType = System.Type.GetType(ParseFieldType(pFields.get_Field(i).Type));
}
IFeatureCursor pFeatureCursor;
pFeatureCursor = pFeatureLayer.FeatureClass.Search(null, false);
IFeature pFeature;
pFeature = pFeatureCursor.NextFeature();
while (pFeature != null)
{
string[] fldValue = new string[pFields.FieldCount];
for (int i = 0; i < pFields.FieldCount; i++)
{
string fldName;
fldName = pFields.get_Field(i).Name;
if (fldName==pFeatureLayer .FeatureClass .ShapeFieldName)
{
fldValue[i] = Convert.ToString(pFeature.Shape.GeometryType);
}
else
fldValue[i] = Convert.ToString(pFeature.get_Value(i));
}
dtGridView.Rows.Add(fldValue);
pFeature = pFeatureCursor.NextFeature();
}
}
参考:http://blog.sina.com.cn/s/blog_84f7fbbb01013ozt.html
http://blog.sina.com.cn/s/blog_8f64865301017rmb.html
另datagridview随form窗体大小变化:http://blog.csdn.net/fengxing11/article/details/52527715
阅读全文
0 0
- C# ArcEngine TOCControl上实现右键
- C# ArcEngine TOCControl上实现右键
- TOCControl右键菜单功能实现
- TOCControl右键菜单
- TOCControl右键菜单
- ArcEngine开发——从TocControl上获取鼠标点击位置的信息(转载)
- TOCControl的常见右键操作
- ArcEngine 鹰眼功能C#实现
- TOCControl代码实现图层名可编辑
- Arcengine实现:在 MapControl 上绘制几何图形
- Arcengine+C#实现矢量数据的裁剪
- TextBox上实现右键菜单
- TextBox上实现右键菜单
- TextBox上实现右键菜单
- TextBox上实现右键菜单
- TextBox上实现右键菜单
- TextBox上实现右键菜单
- ArcEngine中使用上下左右键移动地图功能的实现
- Lintcode 字符大小写排顺序
- PowerDesigner中导出表结构Excel(转载)
- Spring Tool Suite 配置关联代码检查模板
- js对select动态添加和删除OPTION
- 自制轮播图
- C# ArcEngine TOCControl上实现右键
- 深入理解JVM(五)——HotSpot垃圾收集器详解
- 常用技术网站
- 对话框类控件
- android studio fastJson解析数据提示java.lang.NoClassDefFoundError
- Excel公式字符串拼接
- Lintcode96 Partition List solution题解
- JSONP学习
- 分布式架构系统中分布锁的实现