How to add a MapControl to a PageLayoutControl using C# ?

677
1
08-14-2012 07:02 PM
TaiBui
by
Occasional Contributor II
Hi,

I am having a PageLayoutControl on Form that display objects: text, lines,.... Now, I want to add a MapControl to this PageLayoutControl to display a small map (dgn file).

Do you know how to do this ? and Can we set the location for that MapControl ?

Thank you very much,

Tai
0 Kudos
1 Reply
DimaShats
New Contributor III
Hi,

What does it means to add mapcontrol to pagelayout control? do you want to add the layers represented in mapcontrol to pagelayout?
In this case try:

//Get IObjectCopy interface
            IObjectCopy objectCopy = new ObjectCopyClass();

            //Get IUnknown interface (map to copy)
            object toCopyMap = axMapControl1.Map;

           
            //Get IUnknown interface (copied map)
            object copiedMap = objectCopy.Copy(toCopyMap);

            //Get IUnknown interface (map to overwrite)
            object toOverwriteMap = axPageLayoutControl1.ActiveView.FocusMap;

            //Overwrite the MapControl's map
            objectCopy.Overwrite(copiedMap, ref toOverwriteMap);

   Best Reards,
0 Kudos