Deletes a field from this object class.
[Visual Basic 6.0] Sub DeleteField(
ByVal Field As IField _
)
[Visual Basic .NET] Public Sub DeleteField ( _ ByVal Field As IField _ )
[C#] public void DeleteField ( IField Field );
[Java] public void deleteField ( IField Field ) throws IOException, AutomationException
[C++] HRESULT DeleteField( IField* Field );
-2147219878 - FDO_E_FIELD_CANNOT_DELETE_WEIGHT_FIELD
Cannot delete a field that corresponds to an existing weight in a geometric network.
-2147219877 - FDO_E_FIELD_CANNOT_DELETE_REQUIRED_FIELD
Cannot delete a required field. For a list of required fields, see the remarks section. If the field was set as required by the user, (check the IField::Required property and is not one of the fields listed under remarks) IFieldEdit::Required property can be used to remove the required status and then the field can be deleted.
-2147220961 - FDO_E_NO_SCHEMA_LICENSE
You are not licensed to modify the schema of the feature class. This error can arise with an ArcView license when a field is added to a feature class that participates in a Geometric Network, Topology or composite relationship class (such as feature-linked annotation)
-2147215862 - FDO_E_SE_DBMS_DOES_NOT_SUPPORT
Cannot delete a field from DB2.
DeleteField removes the specified field from a table, object class or feature class. Fields that are required by the Geodatabase and cannot be removed include:
// e.g., fieldName = "MyField"
public void IClass__DeleteField(IFeatureClass featureClass, string fieldName)
{
//The following sample code demonstrates one methodology for deleting
//a field using DeleteField
IFields fields = featureClass.Fields;
IField field = fields.get_Field(fields.FindField(fieldName));
//IFeatureClass interface inherits from IClass
featureClass.DeleteField(field);
}
The following sample code demonstrates one methodology for deleting a field using DeleteField
'Assume we have a reference to a feature class, pFC
Dim pFields As IFields
Dim pField As IField
Set pFields = pFC.Fields
Set pField = pFields.Field(pFields.FindField("MyField"))
pFC.DeleteField pField