码迷,mamicode.com
首页 > 其他好文 > 详细

添加和删除字段

时间:2014-10-03 17:48:34      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:datagridview   ar   sp   c   r   ad   ef   new   bs   

添加字段用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();
        }

添加和删除字段

标签:datagridview   ar   sp   c   r   ad   ef   new   bs   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!