About the Retrieve a color ramp from the SymbologyControl Sample
[C#]
SymbolForm.cs
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Display; using ESRI.ArcGIS.esriSystem; namespace ColorRamps { public class Form2 : System.Windows.Forms.Form { private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.Label label1; private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.ComponentModel.Container components = null; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private ESRI.ArcGIS.Controls.AxSymbologyControl axSymbologyControl1; private IClassBreaksRenderer m_classBreaksRenderer; private IStyleGalleryItem m_styleGalleryItem; private IFeatureLayer m_featureLayer; public Form2() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form2)); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.label1 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textBox3 = new System.Windows.Forms.TextBox(); this.textBox2 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.axSymbologyControl1 = new ESRI.ArcGIS.Controls.AxSymbologyControl(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.axSymbologyControl1)).BeginInit(); this.SuspendLayout(); // // comboBox1 // this.comboBox1.Location = new System.Drawing.Point(16, 56); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(168, 21); this.comboBox1.TabIndex = 0; this.comboBox1.Text = "comboBox1"; this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); // // groupBox1 // this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.comboBox1); this.groupBox1.Location = new System.Drawing.Point(304, 24); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(232, 100); this.groupBox1.TabIndex = 1; this.groupBox1.TabStop = false; this.groupBox1.Text = "FeatureLayer"; // // label1 // this.label1.Location = new System.Drawing.Point(16, 32); this.label1.Name = "label1"; this.label1.TabIndex = 1; this.label1.Text = "Numeric Fields:"; // // groupBox2 // this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Controls.Add(this.label2); this.groupBox2.Controls.Add(this.textBox3); this.groupBox2.Controls.Add(this.textBox2); this.groupBox2.Controls.Add(this.textBox1); this.groupBox2.Location = new System.Drawing.Point(304, 128); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(232, 128); this.groupBox2.TabIndex = 1; this.groupBox2.TabStop = false; this.groupBox2.Text = "Break"; // // label4 // this.label4.Location = new System.Drawing.Point(8, 96); this.label4.Name = "label4"; this.label4.TabIndex = 7; this.label4.Text = "Max Value:"; // // label3 // this.label3.Location = new System.Drawing.Point(8, 64); this.label3.Name = "label3"; this.label3.TabIndex = 6; this.label3.Text = "Min Value:"; // // label2 // this.label2.Location = new System.Drawing.Point(8, 32); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(104, 23); this.label2.TabIndex = 5; this.label2.Text = "Number of Classes:"; // // textBox3 // this.textBox3.Enabled = false; this.textBox3.Location = new System.Drawing.Point(120, 96); this.textBox3.Name = "textBox3"; this.textBox3.TabIndex = 4; this.textBox3.Text = ""; // // textBox2 // this.textBox2.Enabled = false; this.textBox2.Location = new System.Drawing.Point(120, 64); this.textBox2.Name = "textBox2"; this.textBox2.TabIndex = 3; this.textBox2.Text = ""; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(120, 32); this.textBox1.Name = "textBox1"; this.textBox1.TabIndex = 2; this.textBox1.Text = ""; this.textBox1.Leave += new System.EventHandler(this.textBox1_Leave); // // groupBox3 // this.groupBox3.Controls.Add(this.axSymbologyControl1); this.groupBox3.Location = new System.Drawing.Point(8, 8); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(288, 288); this.groupBox3.TabIndex = 3; this.groupBox3.TabStop = false; this.groupBox3.Text = "Symbology"; // // axSymbologyControl1 // this.axSymbologyControl1.ContainingControl = this; this.axSymbologyControl1.Location = new System.Drawing.Point(8, 16); this.axSymbologyControl1.Name = "axSymbologyControl1"; this.axSymbologyControl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSymbologyControl1.OcxState"))); this.axSymbologyControl1.Size = new System.Drawing.Size(272, 265); this.axSymbologyControl1.TabIndex = 0; this.axSymbologyControl1.OnItemSelected += new ESRI.ArcGIS.Controls.ISymbologyControlEvents_Ax_OnItemSelectedEventHandler(this.axSymbologyControl1_OnItemSelected); // // button2 // this.button2.Location = new System.Drawing.Point(384, 264); this.button2.Name = "button2"; this.button2.TabIndex = 3; this.button2.Text = "OK"; this.button2.Click += new System.EventHandler(this.button2_Click); // // button3 // this.button3.Location = new System.Drawing.Point(464, 264); this.button3.Name = "button3"; this.button3.TabIndex = 4; this.button3.Text = "Cancel"; this.button3.Click += new System.EventHandler(this.button3_Click); // // Form2 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(546, 304); this.Controls.Add(this.button3); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox2); this.Controls.Add(this.button2); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Name = "Form2"; this.Text = "Class Breaks Renderer"; this.Load += new System.EventHandler(this.Form3_Load); this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox3.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.axSymbologyControl1)).EndInit(); this.ResumeLayout(false); } #endregion private void Form3_Load(object sender, System.EventArgs e) { //Get the ArcGIS install location string sInstall = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path; //Load the ESRI.ServerStyle file into the SymbologyControl axSymbologyControl1.LoadStyleFile(sInstall + "\\Styles\\ESRI.ServerStyle"); //Set the style class axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps; //Select the color ramp item axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass).SelectItem(0); } private void button2_Click(object sender, System.EventArgs e) { //Create a new ClassBreaksRenderer and set properties m_classBreaksRenderer = new ClassBreaksRenderer(); m_classBreaksRenderer.Field = comboBox1.SelectedItem.ToString(); m_classBreaksRenderer.BreakCount = Convert.ToInt32(textBox1.Text); m_classBreaksRenderer.MinimumBreak = Convert.ToDouble(textBox2.Text); //Calculate the class interval by a simple mean value double interval = (Convert.ToDouble(textBox3.Text) - m_classBreaksRenderer.MinimumBreak) / m_classBreaksRenderer.BreakCount; //Get the color ramp IColorRamp colorRamp = (IColorRamp) m_styleGalleryItem.Item; //Set the size of the color ramp and recreate it colorRamp.Size = Convert.ToInt32(textBox1.Text); bool createRamp; colorRamp.CreateRamp(out createRamp); //Get the enumeration of colors from the color ramp IEnumColors enumColors = colorRamp.Colors; enumColors.Reset(); double currentBreak = m_classBreaksRenderer.MinimumBreak; ISimpleFillSymbol simpleFillSymbol; //Loop through each class break for (int i = 0; i <= m_classBreaksRenderer.BreakCount-1; i++) { //Set class break m_classBreaksRenderer.set_Break(i,currentBreak); //Create simple fill symbol and set color simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = enumColors.Next(); //Add symbol to renderer m_classBreaksRenderer.set_Symbol(i, (ISymbol)simpleFillSymbol); currentBreak += interval; } //Hide the form this.Hide(); } private void button3_Click(object sender, System.EventArgs e) { this.Hide(); } private void textBox1_Leave(object sender, System.EventArgs e) { IColorRamp colorRamp = (IColorRamp) m_styleGalleryItem.Item; //Ensure is numeric if (IsInteger(textBox1.Text) == false) { System.Windows.Forms.MessageBox.Show("Must be a numeric!"); textBox1.Text = "10"; return; } else if (Convert.ToInt32(textBox1.Text) <= 0) { //Ensure is not zero System.Windows.Forms.MessageBox.Show("Must be greater than 0!"); textBox1.Text = "10"; return; } else if (Convert.ToInt32(textBox1.Text) > colorRamp.Size) { //Ensure does not exceed number of colors in color ramp System.Windows.Forms.MessageBox.Show("Must be less than " + colorRamp.Size + "!"); textBox1.Text = "10"; return; } } private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e) { //Find the selected field in the feature layer IFeatureClass featureClass = m_featureLayer.FeatureClass; IField field = featureClass.Fields.get_Field(featureClass.FindField(comboBox1.Text)); //Get a feature cursor ICursor cursor = (ICursor) m_featureLayer.Search(null, false); //Create a DataStatistics object and initialize properties IDataStatistics dataStatistics = new DataStatisticsClass(); dataStatistics.Field = field.Name; dataStatistics.Cursor = cursor; //Get the result statistics IStatisticsResults statisticsResults = dataStatistics.Statistics; //Set the values min and max values textBox2.Text = statisticsResults.Minimum.ToString(); textBox3.Text = statisticsResults.Maximum.ToString(); textBox1.Text = "10"; } public IClassBreaksRenderer GetClassBreaksRenderer(IFeatureLayer featureLayer) { m_featureLayer = featureLayer; comboBox1.Items.Clear(); //Add numeric fields names to the combobox IFields fields = m_featureLayer.FeatureClass.Fields; for (int i = 0; i<=fields.FieldCount-1; i++) { if ((fields.get_Field(i).Type == esriFieldType.esriFieldTypeDouble) || (fields.get_Field(i).Type == esriFieldType.esriFieldTypeInteger) || (fields.get_Field(i).Type == esriFieldType.esriFieldTypeSingle) || (fields.get_Field(i).Type == esriFieldType.esriFieldTypeSmallInteger) ) { comboBox1.Items.Add(fields.get_Field(i).Name); } } comboBox1.SelectedIndex = 0; //Show form modally and wait for user input this.ShowDialog(); //Return the ClassBreaksRenderer return m_classBreaksRenderer; } private void axSymbologyControl1_OnItemSelected(object sender, ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent e) { //Get the selected item m_styleGalleryItem = (IStyleGalleryItem) e.styleGalleryItem; } public bool IsInteger(string s) { try { Int32.Parse(s); } catch { return false; } return true; } } }
[Visual Basic .NET]
SymbolForm.vb
Imports ESRI.ArcGIS.Geodatabase Imports ESRI.ArcGIS.Controls Imports ESRI.ArcGIS.Carto Imports ESRI.ArcGIS.Display Imports ESRI.ArcGIS.esriSystem Public Class Form2 Inherits System.Windows.Forms.Form Private m_classBreaksRenderer As IClassBreaksRenderer Private m_styleGalleryItem As IStyleGalleryItem Private m_featureLayer As IFeatureLayer #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents TextBox3 As System.Windows.Forms.TextBox Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents AxSymbologyControl1 As ESRI.ArcGIS.Controls.AxSymbologyControl <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form2)) Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.ComboBox1 = New System.Windows.Forms.ComboBox Me.Label1 = New System.Windows.Forms.Label Me.GroupBox2 = New System.Windows.Forms.GroupBox Me.AxSymbologyControl1 = New ESRI.ArcGIS.Controls.AxSymbologyControl Me.GroupBox3 = New System.Windows.Forms.GroupBox Me.TextBox3 = New System.Windows.Forms.TextBox Me.TextBox2 = New System.Windows.Forms.TextBox Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label4 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Button2 = New System.Windows.Forms.Button Me.Button3 = New System.Windows.Forms.Button Me.GroupBox1.SuspendLayout() Me.GroupBox2.SuspendLayout() CType(Me.AxSymbologyControl1, System.ComponentModel.ISupportInitialize).BeginInit() Me.GroupBox3.SuspendLayout() Me.SuspendLayout() ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.ComboBox1) Me.GroupBox1.Controls.Add(Me.Label1) Me.GroupBox1.Location = New System.Drawing.Point(320, 16) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(248, 120) Me.GroupBox1.TabIndex = 0 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Feature Layer" ' 'ComboBox1 ' Me.ComboBox1.Location = New System.Drawing.Point(16, 56) Me.ComboBox1.Name = "ComboBox1" Me.ComboBox1.Size = New System.Drawing.Size(216, 21) Me.ComboBox1.TabIndex = 1 Me.ComboBox1.Text = "ComboBox1" ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(16, 32) Me.Label1.Name = "Label1" Me.Label1.TabIndex = 0 Me.Label1.Text = "Numeric Fields:" ' 'GroupBox2 ' Me.GroupBox2.Controls.Add(Me.AxSymbologyControl1) Me.GroupBox2.Location = New System.Drawing.Point(16, 8) Me.GroupBox2.Name = "GroupBox2" Me.GroupBox2.Size = New System.Drawing.Size(296, 320) Me.GroupBox2.TabIndex = 0 Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "Symbology" ' 'AxSymbologyControl1 ' Me.AxSymbologyControl1.ContainingControl = Me Me.AxSymbologyControl1.Location = New System.Drawing.Point(8, 16) Me.AxSymbologyControl1.Name = "AxSymbologyControl1" Me.AxSymbologyControl1.OcxState = CType(resources.GetObject("AxSymbologyControl1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxSymbologyControl1.Size = New System.Drawing.Size(280, 296) Me.AxSymbologyControl1.TabIndex = 3 ' 'GroupBox3 ' Me.GroupBox3.Controls.Add(Me.TextBox3) Me.GroupBox3.Controls.Add(Me.TextBox2) Me.GroupBox3.Controls.Add(Me.TextBox1) Me.GroupBox3.Controls.Add(Me.Label4) Me.GroupBox3.Controls.Add(Me.Label3) Me.GroupBox3.Controls.Add(Me.Label2) Me.GroupBox3.Location = New System.Drawing.Point(320, 144) Me.GroupBox3.Name = "GroupBox3" Me.GroupBox3.Size = New System.Drawing.Size(248, 136) Me.GroupBox3.TabIndex = 0 Me.GroupBox3.TabStop = False Me.GroupBox3.Text = "Break" ' 'TextBox3 ' Me.TextBox3.Enabled = False Me.TextBox3.Location = New System.Drawing.Point(128, 104) Me.TextBox3.Name = "TextBox3" Me.TextBox3.TabIndex = 8 Me.TextBox3.Text = "" ' 'TextBox2 ' Me.TextBox2.Enabled = False Me.TextBox2.Location = New System.Drawing.Point(128, 64) Me.TextBox2.Name = "TextBox2" Me.TextBox2.TabIndex = 7 Me.TextBox2.Text = "" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(128, 24) Me.TextBox1.Name = "TextBox1" Me.TextBox1.TabIndex = 6 Me.TextBox1.Text = "" ' 'Label4 ' Me.Label4.Location = New System.Drawing.Point(16, 104) Me.Label4.Name = "Label4" Me.Label4.TabIndex = 5 Me.Label4.Text = "Max Value:" ' 'Label3 ' Me.Label3.Location = New System.Drawing.Point(16, 64) Me.Label3.Name = "Label3" Me.Label3.TabIndex = 4 Me.Label3.Text = "Min Value:" ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(16, 24) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(104, 23) Me.Label2.TabIndex = 3 Me.Label2.Text = "Number of Classes:" ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(416, 296) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 1 Me.Button2.Text = "OK" ' 'Button3 ' Me.Button3.Location = New System.Drawing.Point(496, 296) Me.Button3.Name = "Button3" Me.Button3.TabIndex = 2 Me.Button3.Text = "Cancel" ' 'Form2 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(584, 334) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.GroupBox2) Me.Controls.Add(Me.GroupBox3) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.Name = "Form2" Me.Text = "Class Breaks Renderer" Me.GroupBox1.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) CType(Me.AxSymbologyControl1, System.ComponentModel.ISupportInitialize).EndInit() Me.GroupBox3.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Get the ArcGIS install location Dim sInstall As String = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path 'Load the ESRI.ServerStyle file into the SymbologyControl AxSymbologyControl1.LoadStyleFile(sInstall + "\\Styles\\ESRI.ServerStyle") 'Set the style class AxSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassColorRamps 'Select the color ramp item AxSymbologyControl1.GetStyleClass(AxSymbologyControl1.StyleClass).SelectItem(0) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Create a new ClassBreaksRenderer and set properties m_classBreaksRenderer = New ClassBreaksRenderer m_classBreaksRenderer.Field = ComboBox1.SelectedItem m_classBreaksRenderer.BreakCount = Convert.ToInt32(TextBox1.Text) m_classBreaksRenderer.MinimumBreak = Convert.ToDouble(TextBox2.Text) 'Calculate the class interval by a simple mean value Dim interval As Double interval = (Convert.ToDouble(TextBox3.Text) - m_classBreaksRenderer.MinimumBreak) / m_classBreaksRenderer.BreakCount 'Get the color ramp Dim colorRamp As IColorRamp colorRamp = m_styleGalleryItem.Item 'Set the size of the color ramp and recreate it colorRamp.Size = Convert.ToInt32(TextBox1.Text) colorRamp.CreateRamp(False) Dim i As Integer, currentBreak As Double Dim simpleFillSymbol As ISimpleFillSymbol 'Get the enumeration of colors from the color ramp Dim enumColors As IEnumColors = colorRamp.Colors enumColors.Reset() currentBreak = m_classBreaksRenderer.MinimumBreak 'Loop through each class break For i = 0 To m_classBreaksRenderer.BreakCount - 1 'Set class break m_classBreaksRenderer.Break(i) = currentBreak 'Create simple fill symbol and set color simpleFillSymbol = New SimpleFillSymbolClass simpleFillSymbol.Color = enumColors.Next() 'Add symbol to renderer m_classBreaksRenderer.Symbol(i) = simpleFillSymbol currentBreak += interval Next i 'Hide the form Me.Hide() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Hide() End Sub Public Function GetClassBreaksRenderer(ByVal featureLayer As IFeatureLayer) As IClassBreaksRenderer m_featureLayer = featureLayer ComboBox1.Items.Clear() 'Add numeric fields names to the combobox Dim fields As IFields, i As Integer fields = m_featureLayer.FeatureClass.Fields For i = 0 To fields.FieldCount - 1 If fields.Field(i).Type = esriFieldType.esriFieldTypeDouble Or _ fields.Field(i).Type = esriFieldType.esriFieldTypeInteger Or _ fields.Field(i).Type = esriFieldType.esriFieldTypeSingle Or _ fields.Field(i).Type = esriFieldType.esriFieldTypeSmallInteger Then ComboBox1.Items.Add(fields.Field(i).Name) End If Next ComboBox1.SelectedIndex = 0 'Show form modally and wait for user input Me.ShowDialog() 'return the ClassBreaksRenderer Return m_classBreaksRenderer End Function Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Leave Dim colorRamp As IColorRamp = m_styleGalleryItem.Item 'Ensure is numeric If IsNumeric(TextBox1.Text) = False Then System.Windows.Forms.MessageBox.Show("Must be a numeric!") TextBox1.Text = "10" Exit Sub ElseIf Convert.ToInt32(TextBox1.Text) <= 0 Then 'Ensure is not zero System.Windows.Forms.MessageBox.Show("Must be greater than 0!") TextBox1.Text = "10" Exit Sub ElseIf Convert.ToInt32(TextBox1.Text) > colorRamp.Size Then 'Ensure does not exceed number of colors in color ramp System.Windows.Forms.MessageBox.Show("Must be less than " & colorRamp.Size & "!") TextBox1.Text = "10" Exit Sub End If End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged 'Find the selected field in the feature layer Dim featureClass As IFeatureClass = m_featureLayer.FeatureClass Dim field As IField = featureClass.Fields.Field(featureClass.FindField(ComboBox1.Text)) 'Get a feature cursor Dim cursor As ICursor cursor = m_featureLayer.Search(Nothing, False) 'Create a DataStatistics object and initialize properties Dim dataStatistics As IDataStatistics = New DataStatisticsClass dataStatistics.Field = field.Name dataStatistics.Cursor = cursor 'Get the result statistics Dim statisticsResults As IStatisticsResults statisticsResults = dataStatistics.Statistics 'Set the values min and max values TextBox2.Text = statisticsResults.Minimum TextBox3.Text = statisticsResults.Maximum TextBox1.Text = 10 End Sub Private Sub AxSymbologyControl1_OnItemSelected(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Controls.ISymbologyControlEvents_OnItemSelectedEvent) Handles AxSymbologyControl1.OnItemSelected 'Get the selected item m_styleGalleryItem = e.styleGalleryItem End Sub End Class