Update a legend format with SymbologyControl area and line patches


Purpose
This sample demonstrates using the SymbologyControl to display AreaPatch and LinePatch symbols that are used to update the format of a legend. The sample uses the SymbologyControl in conjunction with the PageLayoutControl, ToolbarControl, and the controls commands.

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. Open a map document.
  2. Add a legend to the PageLayout.
  3. Change the area patch and line patch style by selecting an item from the SymbologyControl.
  4. Delete the legend.

Additional information

A new Legend MapSurround is created and added to the GraphicsContainer of the PageLayout with a name of Legend using the IPageLayoutControl.AddElement method. The IPageLayoutControl.FindElementByName method is used to find the Legend element to delete it using the IGraphicsContainer.DeleteElement method, or update its formatting.
The LoadStyleFile method is used within the Form_Load event of the SymbolForm to add the contents of the ESRI.ServerStyle into the SymbologyControl. The StyleClass property is used to set whether AreaPatch or LinePatch symbols show in the SymbologyControl. Clicking an item shown in the SymbologyControl fires the OnItemSelectedEvent. The ILegend.Format.DefaultAreaPatch is set when the IStyleGalleryItem.Item property implements IAreaPatch, and the ILegend.Format.DefaultLinePatch is set when the IStyleGalleryItem.Item property implements ILinePatch.


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

Download the files for all languages

See Also:

SymbologyControl Class
ISymbologyControl Interface
ISymbologyStyleClass Interface




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