How to add buffer layer to TOCControl without creating feature class

453
2
01-17-2013 08:34 PM
ArunYegi
New Contributor
Hi,

I have created buffer polygon using topological operator. Now i want to add that feature(bufferpolygon feature)to mxd(TOCControl) document.
Ho can i add?Please help..

Regrads,
Arun
0 Kudos
2 Replies
SteveFang
New Contributor III
Hi,

I am not sure it's doable.  If you want your buffer polygon to show up in TOC but without writing to disk, try looking at the InMemoryWorkspaceFactoryClass class to create a temp workspace to put your features in.

Steve
0 Kudos
ArunYegi
New Contributor
Hi,

I tried this, and it worked.

            IFeatureLayer2 featureLayer = (IFeatureLayer2)map.get_Layer(0);
            IFeatureClass featureClass = featureLayer.FeatureClass;

            ////create a new feature(row)
            IFeature feature = featureClass.CreateFeature();
            feature.Shape = buffPolygon;

            IFeatureLayer bufferLayer = new FeatureLayerClass();
            bufferLayer.Name = "Buffer Layer";
            bufferLayer.FeatureClass = featureClass;
            axMapControl1.AddLayer(bufferLayer);


buffPolygon is the buffer created.

I don't know how efficient this code is. But it works fine

Regards,
Arun
0 Kudos