yanasdf789

how to add a  field  ,then set value

Discussion created by yanasdf789 on Oct 10, 2013
Latest reply on Oct 10, 2013 by Neil

//*****Add a Field
 IField2 pField = new Field() as IField2;
                IFieldEdit2 pFieldEdit = pField as IFieldEdit2;
                pFieldEdit.Name_2 = "BldCoding2";
                pFieldEdit.AliasName_2 = "BldCoding2";
                //pFieldEdit.Length_2 = 3;
                pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                pFieldEdit.DefaultValue_2 = "1";
                fcBiuding.AddField(pField);

//*****Then get the index of field

IEnumFeature pEnumFeature = ConstDef.m_Editor.EditSelection;
 IFeature pBuildingFeature = null;
                IFeatureCursor pFeaCur = null;
while ((pBuildingFeature = pEnumFeature.Next()) != null)
{
   int i = pBuildingFeature.Fields.FindField("BldCoding2");//  here  is Error ,i=-1

}
                  


why  I can't  get  the index  of Field???

Outcomes