标签: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