bhavanisankarnimmala

Modify NTS Location Info - Progress bar in ArcMap using arcobjects

Blog Post created by bhavanisankarnimmala on May 14, 2018

private void ModifyNTSLocationInfo()

{

Globals.ws = Common.GetWorkspace();

ITable sampleReportsTable = Common.GetITable("Crown_Sample_Report_NTS", Globals.ws);

IQueryFilter sysTableFilter = new QueryFilter();

sysTableFilter.WhereClause = null;

ICursor updateCursor = sampleReportsTable.Update(sysTableFilter, true);

IRow row = null;

int rowsCnt = sampleReportsTable.RowCount(sysTableFilter);

int cnt = 0;

if (rowsCnt > 0)

{

IStatusBar pStatusBar = null;

IStepProgressor pProgbar = null;

pStatusBar = ArcMap.Application.StatusBar;

pProgbar = pStatusBar.ProgressBar;

pProgbar.Position = 0;

pStatusBar.ShowProgressBar("Land Text Placement is in Progress...", 0, rowsCnt, 1, true);

while ((row = updateCursor.NextRow()) != null)

{

cnt = cnt + 1;

ArcMap.Application.StatusBar.set_Message(0, "Processing " + cnt.ToString() + " / " + rowsCnt.ToString() + "....");

pStatusBar.StepProgressBar();

string ntsLocationInfo = row.get_Value(sampleReportsTable.FindField("LOCN_PARCEL")).ToString(); //071-F/094-H-03

string[] ntsInfo_array = ntsLocationInfo.Split('/');

string[] ntsInfo_sheet = ntsInfo_array[1].ToString().Split('-');

string pq = ntsInfo_sheet[0].ToString();

string lq = ntsInfo_sheet[1].ToString();

string sheet = ntsInfo_sheet[2].ToString();

string[] ntsInfo_part2 = ntsInfo_array[0].ToString().Split('-');

string block = ntsInfo_part2[1].ToString();

string unit = ntsInfo_part2[0].ToString();

int pq_row = sampleReportsTable.FindField("PQ");

row.set_Value(pq_row, pq);

int lq_row = sampleReportsTable.FindField("LQ");

row.set_Value(lq_row, lq);

int mapsheet_row = sampleReportsTable.FindField("MapSheet");

row.set_Value(mapsheet_row, sheet);

int block_row = sampleReportsTable.FindField("Block");

row.set_Value(block_row, block);

int unit_row = sampleReportsTable.FindField("Unit");

row.set_Value(unit_row, unit);

updateCursor.UpdateRow(row);

}

pStatusBar.HideProgressBar();

}

Marshal.ReleaseComObject(updateCursor);

ArcMap.Application.StatusBar.set_Message(0, "COMPLETED....");

}

Outcomes