anncrystal

Help with finding TextElement in PageLayout?

Discussion created by anncrystal on Jun 9, 2011
Latest reply on Sep 1, 2011 by mike.robb
Hi Guys:
This may sound simple to you. But I am stuck. I am trying to find whether there is a disclaimer text in the pagelayout. If not, I want to add one. Here is the code:

if (enumElement != null)
                    {
                    findElement = enumElement.Next();
                    while (findElement != null)
                        {
                        if (findElement is IParagraphTextElement)
                            {
                            findTextElement = findElement as ITextElement;
                          
                            if (findTextElement.Text.EndsWith("></CLR>"))
                                {
                                MessageBox.Show("The Disclaimer Text, which autoupdates the time and date, is already placed in the map.");
                                }
                            else
                                {
                                graphicsContainer.AddElement(element, 0);
                                graphicsContainerSelect.UnselectAllElements();
                                activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                                }
                               
                            }
                        findElement = enumElement.Next();
                        }

                    }


My else part is not working. Where am I wrong? How can I write that if there are no ParagraphtextElements, then add my text?

Thanks in advance for your help.
Ann

Outcomes