1

I am new to ArcObjects

Table

In above attribute table I write query to select "0" in all fields. After I get cursor for looping selected features.but my problem is I want show the FID number and field name which contain "0" attribute values as a message.

for example I want output like:

( fid ,field name

10,NAME

30,NAME

30,FIRST_CONT.........

)

here mycode

    ESRI.ArcGIS.ArcMapUI.IMxDocument mxd = ArcMap.Application.Document as ESRI.ArcGIS.ArcMapUI.IMxDocument;
    ESRI.ArcGIS.Carto.IMap map = mxd.FocusMap;
    ESRI.ArcGIS.Geodatabase.IWorkspaceFactory wsf= new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactory();
    ESRI.ArcGIS.Geodatabase.IWorkspace ws= wsf.OpenFromFile(@"D:\ARC OBJECTS", ArcMap.Application.hWnd);
    ESRI.ArcGIS.Geodatabase.IFeatureWorkspace fws = ws as ESRI.ArcGIS.Geodatabase.IFeatureWorkspace;
    ESRI.ArcGIS.Geodatabase.IFeatureClass fcls = fws.OpenFeatureClass("Find_null");
    ESRI.ArcGIS.Geodatabase.IQueryFilter qf = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
    qf.WhereClause = "FID_1 = 0 OR NAME = '0' OR POPULATION =  0 OR FIRST_CONT = '0'";
    ESRI.ArcGIS.Geodatabase.IFeatureCursor fcur = fcls.Search(qf, true);
    ESRI.ArcGIS.Geodatabase.ICursor cur=fcur as 
    ESRI.ArcGIS.Geodatabase.ICursor;

    ESRI.ArcGIS.Geodatabase.IRow row= cur.NextRow();
    while (row!=null)
    {
      row= cur.NextRow();
    }
  • Can you edit your answer to show exactly what you want as output? NAME// does not exist in any of your rows. It is unclear what you are asking. – Hornbydd Jan 31 '18 at 21:54
  • NAME IS field name. .....i want fid number, field aliase name – Velugoti Venkateswarlu Feb 1 '18 at 11:14
1

I would use something like below. Here is some VB code and basic idea of logic.

dim fid... and other variables
pRow = pCursor.NextRow
Do while not pRow is Nothing
  fid1 = pRow.Value(pRow.FindField("FID_1")
  If pRow.Value(pRow.FindField("NAME")) = "0" Then
    bName = True
  End If
  If pRow.Value(pRow.FindField("POPULATION")) = 0 Then
    bPop = True
  End If
  ' Also FIRST_COUNT

  If bName Then
    Debug.Print Cstr(fid) + ",NAME" 
  End If
  If bPop Then
    Debug.Print Cstr(fid) + ",POPULATION"
  End If
  pRow = pCursor.NextRow
Loop

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.