首页 > 其他 > 详细

添加和删除字段

时间:2014-10-03 16:59:24      阅读:290      评论:0      收藏:0      [点我收藏+]

添加字段用IFeatureClass的AddField 或者 ITable的AddField方法

 

 private void 添加字段ToolStripMenuItem_Click(object sender, EventArgs e)
        {
          IFeatureLayer pFeatureLayer=  pLayer as IFeatureLayer;
       
          IField field = new FieldClass();
          IFieldEdit fieldEdit = field as IFieldEdit;
          fieldEdit.Name_2 = "Point";
    
          fieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
          pFeatureLayer.FeatureClass.AddField(field);
        
          OpenAttribute(); //打开属性表的方法,在这里是起到刷新的作用
        }

删除字段,要先获得删除字段的索引,这里可以从datagridview中获取

 private void 删除字段ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int index = dataGridView1.CurrentCell.ColumnIndex;//获取列索引
         
            IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;

           IField field=   pFeatureLayer.FeatureClass.Fields.get_Field(index);
           MessageBox.Show(field.Name);
           pFeatureLayer.FeatureClass.DeleteField(field);
           OpenAttribute();
        }

添加和删除字段

原文:http://www.cnblogs.com/GiserNet/p/4005059.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!