下例中是对mapControl中当前地图添加“name_city”字段,主要用到IField,IFieldEdit,ITable(IClass),IFeatureLayer,IFeatureClass,IFeature字段,其中IField,IFieldEdit是创建新的字段“name_city”,每个要素的“name_city”字段存储的都是“city_name”。
注意:在调用AddField方法时,利用ITable或者IClass,而不能使用IFieldsEdit,参考AE的帮助文档:
The IFieldsEdit interface is used when creating a fields collection. You cannot use it to insert or delete a field from a fields collection belonging to an existing table. To add a field to an existing object class, use the IClass::AddField method. To remove a field from an existing object class, use the IClass::DeleteField method.
从上面,我们知道IFieldsEdit 在创建新的数据表格时起作用,而要插入或者删除当前已经存在的数据表时,利用IClass。ITable继承于IClass,因此也可以使用ITable。