Can't find MapFrame of GraphicsContainer in PageLayoutControl (C#) ?

662
5
Jump to solution
02-17-2013 11:04 PM
TaiBui
by
Occasional Contributor II
Hi,

I am getting a problem: I added element (text, line) in a ActiveView.FocusMap of a PageLayoutControl, then all elements are showed in the MapFrame of PageLayoutControl.GraphicsContainer.

If I don't select elements (in MapFrame) I can find the MapFrame by the loop:

IGraphicsContainer graphicsContainer = myPageLayout.ActiveView.GraphicsContainer; graphicsContainer.Reset(); IElement pElement = graphicsContainer.Next();  while (pElement != null)             {                 if (pElement is IMapFrame)                 {                       // do something                  }             }


But, when one element is selected by using "Select Elements" command, the program won't enter the "if" function (can't find MapFrame).

Are there anyone know how to get The MapFrame in this case ?

It's very urgent

Thank you very much !
0 Kudos
1 Solution

Accepted Solutions
SiqiLi
by Esri Contributor
Esri Contributor
Thanks Shuping,

Yes, in my code, I didn't include line: pElement = graphicsContainer.Next(); in the while loop.

In your code, you selected shapes of the pagelayout, right ? Is it ok if you add and select shapes within the Focus Map (MapFrame) of the pagelayout ?

Kind regards,



Hi taibc, sorry for the late reply. I think I know what you mean now.
Try to replace:
 IGraphicsContainer graphicsContainer = axPageLayoutControl1.ActiveView.GraphicsContainer

by:
 IGraphicsContainer graphicsContainer = axPageLayoutControl1.GraphicsContainer;


It works at my end.

View solution in original post

0 Kudos
5 Replies
TaiBui
by
Occasional Contributor II
Are there anyone can help ?
0 Kudos
SiqiLi
by Esri Contributor
Esri Contributor
Just tested and it works fine at my end. See the attached screen shot.
BTW, your code has an infinite loop!
Let me know if I misunderstood the issue. [ATTACH=CONFIG]22040[/ATTACH]
0 Kudos
TaiBui
by
Occasional Contributor II
Thanks Shuping,

Yes, in my code, I didn't include line: pElement = graphicsContainer.Next(); in the while loop.

In your code, you selected shapes of the pagelayout, right ? Is it ok if you add and select shapes within the Focus Map (MapFrame) of the pagelayout ?

Kind regards,
0 Kudos
SiqiLi
by Esri Contributor
Esri Contributor
Thanks Shuping,

Yes, in my code, I didn't include line: pElement = graphicsContainer.Next(); in the while loop.

In your code, you selected shapes of the pagelayout, right ? Is it ok if you add and select shapes within the Focus Map (MapFrame) of the pagelayout ?

Kind regards,



Hi taibc, sorry for the late reply. I think I know what you mean now.
Try to replace:
 IGraphicsContainer graphicsContainer = axPageLayoutControl1.ActiveView.GraphicsContainer

by:
 IGraphicsContainer graphicsContainer = axPageLayoutControl1.GraphicsContainer;


It works at my end.
0 Kudos
TaiBui
by
Occasional Contributor II
Great ! It is successful now.

Thanks Shuping very much  !

Kind regards,
0 Kudos