Select to view content in your preferred language

Printing field name and rows

443
1
01-13-2014 02:40 AM
jayakumar
Emerging Contributor
Hi,
           
IMapDocument pmd = new MapDocumentClass();

           
            if (pmd.get_IsMapDocument(@"F:/Projects/Inprogress.mxd"))
            {
                pmd.Open(@"F:/Projects/Inprogress.mxd", null);
                IMap pmap;
                  

                for (int i = 0; i <= pmd.MapCount - 1; i++)
                {
                    pmap = pmd.get_Map(0);
                    Console.WriteLine(pmap.Name);
                    for (int layerIndex = 0; layerIndex < pmap.LayerCount; layerIndex++)
                    {
                        ILayer layer = pmap.get_Layer(layerIndex);
                        IFeatureLayer FL = layer as IFeatureLayer;
                        Console.WriteLine(FL.Name);
                     }
   After this I want to print the Field names of each class and the containing attributes, how to do that in next steps.
0 Kudos
1 Reply
DuncanHornby
MVP Notable Contributor
As you are getting IFeatureLayers you would then get a handle on the FeatureClass. This gives you access the Fields which you can iterate over to retrieve the field names. If you want to read the actual values of each Feature then you need to create a FeatureCursor and iterate over this. There are many examples in the help and on this forum.
0 Kudos