Solved! Go to Solution.
public void StartButton_Click(object sender, EventArgs e)
{
IApplication app = (IApplication)this.Hook;
IMxDocument mapDoc = (IMxDocument)app.Document;
IFeatureLayer featureLayer = (IFeatureLayer)mapDoc.SelectedLayer;
GetSelectedValues(featureLayer);
}
private void GetSelectedValues(IFeatureLayer featureLayer)
{
IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
ISelectionSet selectionSet = featureSelection.SelectionSet;
ICursor cursor;
selectionSet.Search(null, false, out cursor);
IRow row = cursor.NextRow();
textBox2.Text = row.OID.ToString();
while (cursor != null)
{
System.Diagnostics.Debug.WriteLine(row.OID.ToString());
row = cursor.NextRow();
}
}
It looks like you switched to VB Code on the line that reads:
IFeatureSelection featureSelection = featureLayer as IFeatureSelection;(example 1)
I believe it should be:
IFeatureSelection featureSelection = (IFeatureSelection)featureLayer;(example 2)