I have a combo box that has the layers from the TOC loaded into them. Now I want to be able to select the layer (usually shapefiles) and load the fields but im a newbie when it comes to ArcObjects.
This is what I have which i know is wrong:
private void cboLocation_SelectedIndexChanged(object sender, EventArgs e)
{
cboRegion.Items.Clear();
cboLevel.Items.Clear();
PointLayers selectedPntLayer = cboLocation.SelectedItem as PointLayers;
IFeatureLayer selectedFL = selectedPntLayer.pointLayer as IFeatureLayer;
IFeatureClass getInputFC = selectedFL.FeatureClass ;
for (int i = 0; i < getInputFC.Fields.FieldCount; i++)
{
cboRegion.Items.Add(getInputFC.Fields.get_Field(i).Name);
cboLevel.Items.Add(getInputFC.Fields.get_Field(i).Name);
}
}
I get an error at the IFeatureLayer line saying:
"Object reference not set to an instance of an object."
Im sure it is easy to fix but im a newbie, anyone out there know how to fix this?