ArcObjects TextBox on Map Document

4660
20
04-07-2014 11:28 AM
JamariPowers
New Contributor III
ArcMap 10.0
Arc Objects
Visual Studio 2010

I am new to using ArcObjects and have been getting more and more familiar with ArcMap. I am using Visual Studio and been having trouble creating / placing a simple textbox on an mxd. I am working in C#. I have a toolbar with buttons and hope to accomplish this on button click. The text box should be able to support text inside it as well.

Trying to start off small and work my way up. Any help on this topic would be greatly appreciated. Thanks in advance.
0 Kudos
20 Replies
LeoDonahue
Occasional Contributor III
And because I am using C# and don't exaclty know of all the references needed to import,

You will likely have several of the same references that I imported using Java in .NET.

I still have no real understanding of all the misc other function calls  (SimpleMarkerSymbol, MarkerElement, etc). I can look up their meaning  but do not understand really why they are needed or why they  should/would be needed


You should start here:  GraphicsContainer  addElement()  - this is really your objective.  Add some text to a map. 

Now that you have found a starting point, you work your way through the API.

I gave you the namespace for GraphicsContainer: Carto

So go here:  IGraphicsContainer.AddElement Method

Do you see where IElement is a parameter to this method call?  It's right there in the C# sample.

So go here:  IElement Interface

What kind of element do you want?  TextElment?  There is one of those, just click on it.

You should now be here:  TextElementClass Class  

Now click on ITextElement in that page.

What does this class need to do it's job?  Answer:  It needs Text and a Symbol.  And everything that inherites from IElement will need to have a geometry.  So you need to go look at what it takes to create a geometry, like a point.

What kind of symbols are there?  Answer:  ISymbol Interface

As you work your way through the seemingly simple task of adding a TextElement to a map, you discover that there is alot more that you need to do to get the job done.

You don't necessarily need the marker symbol, I just threw that in there for the sake of displaying the dot.  I could have left it out, I could have left out the Group Element and I could have moved the code from getMapCoordinatesFromScreenCoordinates up into the other part of the code.

Code without explanation in my context won't really help

You are welcome for the post. Good luck.