我创建了点要素。但是不能添加数据属性表。
IMxDocument pMxdoc = ArcMap.Application.Document as IMxDocument;
IPoint pPoint = pMxdoc.ActivatedView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);
IFeatureLayer pFLayer = pMxdoc.FocusMap.Layer[3] as IFeatureLayer;
IWorkspaceEdit pWSE = ((IDataset)(pFLayer.FeatureClass)).Workspace as IWorkspaceEdit;
pWSE.StartEditing(false);
pWSE.StartEditOperation();
IFeature pFeature = pFLayer.FeatureClass.CreateFeature();
pFeature.Shape = pPoint;
pFeature.Store();
// I want to add data in table this here but how?
pWSE.StopEditOperation();
pWSE.StopEditing(true);
pMxdoc.ActivatedView.Refresh();
答案 0 :(得分:3)
您只需为要素指定几何图形,但可能还需要其他属性。因此,您应使用set_Value
设置当前要素的属性值:
int fieldIndex = myFeatureClass.FindField(attributeName);
object newValue = "newValue";
IFeature pFeature = pFLayer.FeatureClass.CreateFeature();
pFeature.set_Value(fieldIndex, newValue);
pFeature.Shape = pPoint;
pFeature.Store();