Remove layer LYR from map control

Discussion created by filippa on Feb 28, 2012
Latest reply on Mar 1, 2012 by priyanka_mehta
Hi forum
I use ArcMap 9.3.1 and ArcObjects, I have created a windows application with a map control.
In the axTOCControl I have added layer lyr with the follow code
 public IFeatureLayer AddLayerLyr(ESRI.ArcGIS.Carto.IActiveView activeView, string layerPathFile, AxMapControl axm)

            //Create a new GxLayer.
            IGxLayer gxLayerCls = new GxLayer();
            IGxFile gxFile = (IGxFile)gxLayerCls;
            //Explicit Cast.

            //Set the path for where the layer file is located on disk.
            gxFile.Path = layerPathFile;

            //Test if you have a valid layer and add it to the map.
            if (!(gxLayerCls.Layer == null))
                IMap map = axm.Map;   // activeView.FocusMap;
            return ((IFeatureLayer)gxLayerCls.Layer);

Now, how can I remove lyr from toc anc from map?
I would like add code to contex menu or to a button with which delete the selected lyr, how can I do it?

Can you help me please?

Thank you so much!!!