AE+C#:实现ArcMap中打开图层属性表后按属性选择的功能
更新时间:2024-01-27 21:42:01 阅读量: 教育文库 文档下载
AE+C#:实现ArcMap中打开图层属性表后按属性选择的功能
此文档仅按以下界面实现按属性选择的主要功能,作为初学者的尝试,代码有很多不完善的地方,在此发出来和大家交流学习。
1、从主窗口的MapControl中获取Map的各个图层
2、从ComboBox中选择图层后,在listBox1中显示该图层所有的字段
3、从listBox1选择字段并单击获取唯一值后,将该字段所有唯一值显示到listBox2中
4、双击listBox中的项会添加到下面的textBox中,单击应用后将SQL语句返回到主窗口中
1、新建窗体,设置属性如下: 属性 属性值 Name frmQueryFeat Text 按属性查询 MaximizeBox False MinimizeBox False FormBorderStyle FixedSingle
2、设置好窗体后,如上图所示在窗口上添加各类控件: 控件 Name属性 Text属性 ComboBox featCls_comboBox - ListBox field_listBox - ListBox uniqueValue_listBox - Button UniqueValue_button 获取唯一值 Button apply_button 应用 Button close_button 关闭 Button clear_button 清除 TextBox textBox1 - Label数个(用于显示提示) - - Button数个(用于添加SQL语句的=,- - <>,>,<,and ,or等)
3、添加一个类,对项目单击右键→添加→类,设置类的名称为FeatureClassInfo: ///
/// 表示要素类及其所在图层的图层名、图层索引 ///
public class FeatureClassInfo {
private int _lyrIndex; private string _lyrName;
private IFeatureClass _featCls;
public Int32 LayerIndex { get { return _lyrIndex; } } public String LayerName { get { return _lyrName; } }
public IFeatureClass FeatureClass { get { return _featCls; } }
public FeatureClassInfo(int lyrIndex,string lyrName,IFeatureClass featCls) {
this._lyrIndex = lyrIndex; this._lyrName = lyrName; this._featCls = featCls; } }
4、在frmQueryFeat窗口中输入以下代码: using System;
using System.Collections;
using System.Collections.Generic; using System.Windows.Forms; using ESRI.ArcGIS.Geodatabase;
namespace GISsys {
public partial class frmQueryFeat : Form {
private List
public frmQueryFeat(FeatureClassInfo[] featClsesInfo) {
InitializeComponent();
foreach (var f in featClsesInfo) {
this.featCls_comboBox.Items.Add(f.LayerName); _fInfoList.Add(f); }
if (featClsesInfo.Length > 0) {
_fInfo = _fInfoList[0];
this.featCls_comboBox.SelectedIndex = 0; sql_textBox.Focus(); //_featureClass (IFeatureClass)this.featCls_comboBox.SelectedItem; } }
#region 各÷类え?函ˉ数簓
///
/// 返う?回?通?过y属?性?查é询ˉ要癮素?的?SQL语?句? ///
///
return this.sql_textBox.Text.Trim(); }
///
/// 返う?回?要癮执′行D查é询ˉ的?图?层?索÷引皔 ///
///
return this.featCls_comboBox.SelectedIndex;
= }
#endregion
#region 符?号?按恪?钮¥事?件t
private void button1_Click(object sender, EventArgs e) {
sql_textBox.Text += \; }
private void button2_Click(object sender, EventArgs e) {
sql_textBox.Text += \; }
private void button3_Click(object sender, EventArgs e) {
sql_textBox.Text += \; }
private void button5_Click(object sender, EventArgs e) {
sql_textBox.Text += \; }
private void button4_Click(object sender, EventArgs e) {
sql_textBox.Text += \; }
private void button6_Click(object sender, EventArgs e) {
sql_textBox.Text += \; }
private void button7_Click(object sender, EventArgs e) {
sql_textBox.Text += \; }
private void button9_Click(object sender, EventArgs e)
{
sql_textBox.Text += \; }
private void button8_Click(object sender, EventArgs e) {
sql_textBox.Text += \; }
private void button10_Click(object sender, EventArgs e) {
sql_textBox.Text += \; }
#endregion
private void featCls_comboBox_SelectedIndexChanged(object sender, EventArgs e) {
this.field_listBox.Items.Clear();
this.uniqueValue_listBox.Items.Clear();
int index = featCls_comboBox.SelectedIndex; _fInfo = _fInfoList[index];
int flds_cnt = _fInfo.FeatureClass .Fields.FieldCount;
for (int i = 0; i < flds_cnt; i++) {
IField field = _fInfo.FeatureClass.Fields.get_Field(i); //if (field.Editable) //{
// _Valuefields.Add(new ValueField(field)); //}
field_listBox.Items.Add(field.Name); }
}
private void UniqueValue_button_Click(object sender, EventArgs e) {
int index = this.featCls_comboBox.SelectedIndex; FeatureClassInfo featClsInfo = _fInfoList[index]; ArrayList list = new ArrayList();
if (this.field_listBox.SelectedIndex != -1) {
UniqueValueClass uniqueVaueCls = new UniqueValueClass();
list = uniqueVaueCls.GetLayerUniqueFieldValueByDataStatistics( featClsInfo.FeatureClass, this.field_listBox.SelectedItem.ToString());
this.uniqueValue_listBox.Items.Clear(); foreach (var f in list) {
this.uniqueValue_listBox.Items.Add(f); } } }
private void field_DoubleClick(object sender, EventArgs e) {
sql_textBox.Text += field_listBox.SelectedItem.ToString(); }
private void uniqueValue_DoubleClick(object sender, EventArgs e) {
IField field = _fInfo.FeatureClass.Fields.get_Field(field_listBox.SelectedIndex); if (field.Type == esriFieldType.esriFieldTypeString) {
sql_textBox.Text += \+uniqueValue_listBox.SelectedItem.ToString()+\; } else {
sql_textBox.Text += uniqueValue_listBox.SelectedItem.ToString(); } }
private void clear_button_Click(object sender, EventArgs e) {
sql_textBox.Text = \; }
private void apply_button_Click(object sender, EventArgs e) {
this.DialogResult = DialogResult.OK; this.Close();
}
private void close_button_Click(object sender, EventArgs e) {
this.DialogResult = DialogResult.Cancel; this.Close(); }
} }
5、在主窗口事件中调用:
List
if (featClsInfoList.Count > 0) {
//打洙?开a查é询ˉ窗洹?口ú frmQueryFeat queryFeatForm = new frmQueryFeat(featClsInfoList.ToArray());
if (queryFeatForm.ShowDialog() == DialogResult.OK) {
int lyrindex = queryFeatForm.LayerIndex();//要癮查é询ˉ的?图?层?
string sql = queryFeatForm.SQL();//查é询ˉ语?句?
IFeatureLayer featureLyr =
axMapControl1.Map.get_Layer(lyrindex) as IFeatureLayer;
searchSelection(sql, featureLyr);//执′行D查é询ˉ } } else {
MessageBox.Show(\缺ā?少Θ?要癮素?图?层?!?\, \提?示?\, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
正在阅读:
AE+C#:实现ArcMap中打开图层属性表后按属性选择的功能01-27
写景状物作文800字8篇02-05
继续教育《专业技术人员信息化能力建设(1)(2013 年公共课)》(2)09-20
测试技术与信号处理题库07-09
树给我上了一课作文700字06-23
大连市人民政府关于印发《大连市城市住宅区物业管理办法》的通知11-22
理解不了作文350字06-22
暑假日记200字15篇02-21
电阻点焊方法和工艺10-16
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 属性
- 打开
- 实现
- 功能
- 选择
- ArcMap
- AE
- MPA考试英语作文参考范文
- 2016年尔雅《学术基本要素:专业论文写作》期末考试
- 中学生手机里藏着十个秘密
- 广东省医疗用品及器材零售公司名录2018版2375家 - 图文
- 最新塔吊备案资料、塔吊检测资料2014 - 图文
- 2016超星尔雅大学生职业生涯规划考试答案
- 岗位考试公共课程试题
- 岳麓版高中历史选修三单元测试题及答案全套
- 新型智慧城市大脑建设方案 - 图文
- 2017年部编八年级语文上册古诗文理解性默写
- 长方体和正方体体积容积练习题
- 北京工商大学法律硕士考研高分经验分类介绍
- 新北师大版六年级下册数学教学反思
- “两新组织”党建制度
- 已知三角函数值求角
- 2016年矿井灾害预防和处理计划
- 小班体育活动教案:皮球滚得快
- 2011-2015年辽宁省环保产业投资分析及前景预测报告
- 高一英语人教版必修4 - Unit1 - A - Student - of - African - Wildlife - 全英文说课稿
- 高中历史政治文明历程 - 图文