【问题标题】:How to creating point features and add data in attibute table at the same time?如何在属性表中同时创建点要素和添加数据?
【发布时间】:2017-10-31 22:30:52
【问题描述】:

我创建了点要素。但我不能添加数据属性表。

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();

【问题讨论】:

    标签: c# arcgis arcmap arcobjects


    【解决方案1】:

    您只是为要素分配几何,但您可能需要更多属性。因此,您应该使用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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-10
      • 1970-01-01
      • 2020-08-26
      相关资源
      最近更新 更多