ArcGIS 中要素的查询与修改


转自nimeila的回答 求C# ArcGIS Engine修改选中要素的属性,单要素都行

 

复制代码
RLAlterFrm RLalter = new RLAlterFrm();
RLalter.ShowDialog();

string AlterID = RLalter.textBox1.Text;
string AlterRP = RLalter.textBox2.Text;
string AlterC = RLalter.textBox3.Text;

axMapControl1.ClearLayers();
axMapControl1.Refresh();

try
{
    string strFileName = Application.StartupPath + @"\数据\Roadlamp.mxd";
    //在数据视图中加载地图,供查询操作
    if (axMapControl1.CheckMxFile(strFileName))
    {
        axMapControl1.LoadMxFile(strFileName);
    }
    else
    {
        MessageBox.Show("错误的数据路径:" + strFileName);
    }
}
catch (Exception ex)
{
    MessageBox.Show("Error01 in MainForm.cs" + ex.Message);
}
axMapControl1.Refresh();

string strQK = RLalter.getQueryKey();//获取查询值

//找到图层
IFeatureLayer pfeaturelayer = new FeatureLayer();
pfeaturelayer = axMapControl1.get_Layer(0) as IFeatureLayer;

//找到要素
IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = "[RL_ID] = '" + strQK + "'";

IFeatureCursor pFeatureCur = pfeaturelayer.Search(pQueryFilter, false);

IFeature pFeature = null;

pFeature = pFeatureCur.NextFeature();

if (null == pFeature)
{
    MessageBox.Show("对不起!该元素不存在");
}

else
{
    IFields pFields = pFeature.Fields;
IFeatureClass pFeatureClass = pfeaturelayer.FeatureClass;

    //修改属性值 
    int field1 = pFields.FindField("RL_ID");
    int field2 = pFields.FindField("RL_RP");
    int field3 = pFields.FindField("RL_C");
    pFeature.set_Value(field1, AlterID);
    pFeature.set_Value(field2, AlterRP);
    pFeature.set_Value(field3, AlterC);
    pFeature.Store();
    MessageBox.Show("修改成功!","提示");
}
}
复制代码

 

没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。




    本文转自wenglabs博客园博客,原文链接:http://www.cnblogs.com/arxive/p/6322023.html ,如需转载请自行联系原作者

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值