0

How to add a field in featureclass by using C# winform,arcobjects?

It means when we click on command winform should open and afetr field entries it should be add in to table.

  • Can you please post some code to show where you're stuck. You can use Windows Forms to access ArcObjects, either as an add-in or a standalone program (I would need to know which one it is) also, is it a local dataset or do you intend to do this over a web interface? – Michael Stimson Nov 24 '14 at 23:19
1

The following function will add a field to a feature class:

private void AddField(IFeatureClass fClass, string name, string alias, esriFieldType dataType)
{
    IField newField = new FieldClass();
    IFieldEdit fieldEdit = (IFieldEdit)newField;
    fieldEdit.Name_2 = name;
    fieldEdit.AliasName_2 = alias;
    fieldEdit.Type_2 = dataType;

    fClass.AddField(newField);
}

There are, of course, more properties that can be set on the field, this is just a sample of how to set them - the properties ending '_2' on IFieldEdit are the writable ones.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.