Draw text on a MapControl


Purpose
This draw text sample application demonstrates the splined text rendering capabilities of ArcObjects. When you click the map to track a line, the MapControl method DrawText is used to place the text within the text box along the tracked line. At least two clicks are required for the line and text to appear on the MapControl.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Type the text to annotate the map.
  2. Use the left mouse button to trace a line on the map, and use the right mouse button to zoom in.

Additional information

The application uses the AddLayerFromFile method to load the world continents sample data, which is then symbolized. The OnClick event either uses the TrackRectangle method to zoom in (if the right or middle mouse button has been used) or adds the new point to the line and updates the display through the Refresh method. The Refresh method is used to draw the esriViewForeground, thereby removing any previously drawn annotation and triggering the MapControl's OnAfterDraw event. The OnAfterDraw event uses the DrawShape and DrawText methods to draw the line and text onto the MapControl in response to the refresh of the esriViewForeground phase.


AssemblyInfo.cs Assembly information.
DrawText.cs Form file.
Download the C# files
AssemblyInfo.vb Assembly information.
DrawText.vb Form file.
Download the VB.NET files

Download the files for all languages

See Also:

MapControl class
IMapControl2 interface




Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced