How to add a feature to a feature class from shape file?

1302
2
Jump to solution
05-16-2012 09:23 AM
SuiHuang
Occasional Contributor II
Hi Experts:

    Following is the code I wrote to add a point feature to a shape file.

//*********************************************************************
public static void AddToFeatureClass(IFeatureClass baseClass, IGeometry newGeometry)
{
    IFeature newFeature = baseClass.CreateFeature();
    newFeature.Shape = newGeometry;
    (newFeature.Shape as IZAware).ZAware = (newGeometry as IZAware).ZAware;
    (newFeature.Shape as IMAware).MAware = (newGeometry as IMAware).MAware;
}
//*********************************************************************

    The code could run through and add a record into the shape file. However, in ArcMap attribute table there is no response when I zoom/pan/flash the added point. When I idenfy the point I found that it has an undefined location (see the following screenshoot).

[ATTACH=CONFIG]14373[/ATTACH]

    When I use the Visual Studio debug mode to inspect the new feature, I couldn't find any issue.
[ATTACH=CONFIG]14374[/ATTACH]

    What does it happen? How shall I fix the issue? If more information is needed please let me know. Thank you.
0 Kudos
1 Solution

Accepted Solutions
NeilClemmons
Regular Contributor III
If you don't call IFeature.Store then any changes you make to the feature will not be saved.

View solution in original post

0 Kudos
2 Replies
NeilClemmons
Regular Contributor III
If you don't call IFeature.Store then any changes you make to the feature will not be saved.
0 Kudos
by Anonymous User
Not applicable
Original User: huangs3

If you don't call IFeature.Store then any changes you make to the feature will not be saved.


Great! It works, thank you.
0 Kudos