AE+C#:实现ArcMap中打开图层属性表后按属性选择的功能

2019-08-26 17:06

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 _fInfoList = new List(); private FeatureClassInfo _fInfo = null;

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语?句? ///

/// public string SQL() {

return this.sql_textBox.Text.Trim(); }

///

/// 返う?回?要癮执′行D查é询ˉ的?图?层?索÷引皔 ///

/// public int LayerIndex() {

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();


AE+C#:实现ArcMap中打开图层属性表后按属性选择的功能.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2015-2016学年度上期小学考务工作的安排

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: