[![enter image description here][1]][1]I'm trying to write a C# .NET add-in for ArcMap and I need some help. I want to be able to select a set of features in an SDE and then click a button that would add the selected features' field to a data grid view. I have been able to have selected features be added to a list box with a button but I can't modify the code to be a data grid. Below is my code so far after I've set up the SDE workspace.
IEnumFeature pEnumFeat = (IEnumFeature)Pmap.FeatureSelection;
IFields fields;
pEnumFeat.Reset();
IEnumFeatureSetup enumFeatSetup = (IEnumFeatureSetup)pEnumFeat;
enumFeatSetup.AllFields = true;
try
{
IFeature pfeat = pEnumFeat.Next();
while (pfeat != null)
{
fields = pfeat.Fields;
int x = fields.FindField("NAME OF FIELD");
list.Add(pfeat.get_Value(x).ToString());
Debug.Print(pfeat.get_Value(x).ToString());
if (pfeat.get_Value(x).ToString() != "")
LstBxWellList.Items.Add(pfeat.get_Value(x).ToString());
pfeat = pEnumFeat.Next();
}
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
return;
}