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)
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(); } }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.