我正在尝试转换为 C# 的 Vba 代码。我已经非常接近了,但我可以弄清楚为什么我不断收到这个错误。错误无法将方法组“NextFeature”转换为非委托类型“ESRI.ArcGIS.Carto.IFeatureSelection”。您是否打算调用该方法?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
namespace ArcMapAddin1
{
public partial class frmParcelReader : Form
{
public frmParcelReader()
{
InitializeComponent();
}
public void ReadData()
{
//IMxDocument pMxDoc = default(IMxDocument);
IMxDocument pMxDoc = ArcMapAddin1.ArcMap.Document;
//IMap pMap = default(IMap);
IMap pMap = pMxDoc.FocusMap;
//IFeatureSelection pFLayer = default(IFeatureSelection);
IFeatureLayer pLayer = pMap.get_Layer(0) as IFeatureLayer;
IFeatureSelection pFLayer = pLayer as IFeatureSelection;
string stopHere2 = "";
for (int Count = 0; Count <= pMap.LayerCount - 1; Count++) {
//if (pMap.LayerCount == "sde.GIS.parcels_adacounty")
if (pLayer.Name == "sde.GIS.parcels_adacounty")
{
//pFLayer = pMap.get_Layer(0)
//string thisString = pFLayer.SelectionSet.IDs.ToString();
IFeatureCursor pFCursor = null;
//pFLayer.SelectionSet.Search(null, false, pFCursor);
//IFeature pFLayer = pLayer(IFeature);
pFLayer = pFCursor.NextFeature;
if (pFLayer.SelectionSet.Count != 0) {
//lblParcel.Text = pF.Value.Fields.FindField("PARCEL");
//lblPrimaryOwner.Text = pF.Value(pF.Fields.FindField("PRIMOWNER"));
//lblMailingAddress.Text = pF.Value(pF.Fields.FindField("ADDCONCAT"));
//lblPropertyAddress.Text = pF.Value(pF.Fields.FindField("ADDRESS"));
} else {
//if (sender == "Button")
// MessageBox.Show("Please select a Parcel.");
}
break; // TODO: might not be correct. Was : Exit For
}
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
ReadData();
}
}
}