AE中添加属性字段

C# code
//2011年2月23日
//来源:互联网
//***********************************************
pFeatureLayer = pLayer as IFeatureLayer;
pFeatureClass = pFeatureLayer.FeatureClass;
IField pField = new FieldClass();
IFieldEdit pFieldEdit = pField as IFieldEdit;
pFieldEdit.Name_2 = textBoxFieldName.Text.ToString();
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
pFieldEdit.AliasName_2 = textBoxFieldAlias.Text.ToString();
pFeatureClass.AddField(pFieldEdit);
//***********************************************

IFieldEdit是在创建字段的时候使用的,可以设置字段的类型、名称、别名等,IField是只读的,不能设置字段本身的属性(如名称、类型、别名),另外在.NET语言中使用时,需要在IFieldEdit的属性后加上“_2”。修改已有字段的属性,使用IClassSchemaEdit。

原文地址:https://www.cnblogs.com/xingchen/p/1962234.html