Retrieve a color ramp from the SymbologyControl


Purpose
This sample demonstrates how to retrieve a color ramp from the SymbologyControl and use it within a ClassBreaksRenderer. 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 and select a polygon feature layer.
  2. Select a color ramp and field, then set the number of classes.

Additional information

When a document is loaded into the PageLayoutControl, the OnPageLayoutReplaced event is fired and used to populate a combo box with a list of polygon feature classes implementing IGeoFeatureLayer. The layer selected in the combo box is rendered with a ClassBreaksRenderer using the IGeoFeatureLayer.Renderer property.
Within the Form_Load event of the SymbolForm, the LoadStyleFile method is used to add the contents of the ESRI.ServerStyle into the SymbologyControl, and the StyleClass property is used to show color ramps. A combo box is populated with the names of the numeric fields within the FeatureClass. The minimum and maximum values within selected fields are shown using the IStatisticsResults.Maximum and IStatisticsResults.Minimum properties.
Clicking an item in the SymbologyControl passes the selected IStyleGalleryItem object to the OnItemSelected event. A ColorRamp is returned from the IStyleGalleryItem.Item property. The IColorRamp.Size and IClassBreaksRenderer.BreakCount properties are set to the number of classes specified by the end user. For each break in the ClassBreaksRenderer, the IClassBreaksRenderer.Symbol is set with a SimpleFillSymbol.Color specified by the next color in the ColorRamp.


AssemblyInfo.cs Assembly information.
ColorRamps.cs Form file.
SymbolForm.cs Form file.
Download the C# files
AssemblyInfo.vb Assembly information.
ColorRamps.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