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();
 }
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jan 31, 2018 at 20:54
2
  • 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. Commented Jan 31, 2018 at 21:54
  • NAME IS field name. .....i want fid number, field aliase name Commented Feb 1, 2018 at 11:14

1 Answer 1

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
answered Feb 1, 2018 at 14:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.