This document is archived and information here might be outdated.  Recommended version.


Create Simple Fill Symbol Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Create Simple Fill Symbol Snippet

Create a simple fill symbol by specifying a color, outline color and fill style.

[C#]
///<summary>Create a simple fill symbol by specifying a color, outline color and fill style.</summary>
///  
///<param name="fillColor">An IRGBColor interface. The color for the inside of the fill symbol.</param>
///<param name="fillStyle">An esriSimpleLineStyle enumeration for the inside fill symbol. Example: esriSFSSolid.</param>
///<param name="borderColor">An IRGBColor interface. The color for the outside line border of the fill symbol.</param>
///<param name="borderStyle">An esriSimpleLineStyle enumeration for the outside line border. Example: esriSLSSolid.</param>
///<param name="borderWidth">A System.Double that is the width of the outside line border in points. Example: 2</param>
///   
///<returns>An ISimpleFillSymbol interface.</returns>
///  
///<remarks></remarks>
public ESRI.ArcGIS.Display.ISimpleFillSymbol CreateSimpleFillSymbol(ESRI.ArcGIS.Display.IRgbColor fillColor, ESRI.ArcGIS.Display.esriSimpleFillStyle fillStyle, ESRI.ArcGIS.Display.IRgbColor borderColor, ESRI.ArcGIS.Display.esriSimpleLineStyle borderStyle, System.Double borderWidth)
{
  
  if(fillColor == null || fillStyle == null || borderColor == null || borderStyle == null)
  {
    return null;
  }
  ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol=new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
  simpleLineSymbol.Width=borderWidth;
  simpleLineSymbol.Color=borderColor;
  simpleLineSymbol.Style=borderStyle;

  ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol=new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
  simpleFillSymbol.Outline=simpleLineSymbol;
  simpleFillSymbol.Style=fillStyle;
  simpleFillSymbol.Color=fillColor;

  return simpleFillSymbol;
}
[Visual Basic .NET]
'''<summary>Create a simple fill symbol by specifying a color, outline color and fill style.</summary>
'''  
'''<param name="fillColor">An IRGBColor interface. The color for the inside of the fill symbol.</param>
'''<param name="fillStyle">An esriSimpleLineStyle enumeration for the inside fill symbol. Example: esriSFSSolid.</param>
'''<param name="borderColor">An IRGBColor interface. The color for the outside line border of the fill symbol.</param>
'''<param name="borderStyle">An esriSimpleLineStyle enumeration for the outside line border. Example: esriSLSSolid.</param>
'''<param name="borderWidth">A System.Double that is the width of the outside line border in points. Example: 2</param>
'''   
'''<returns>An ISimpleFillSymbol interface.</returns>
'''  
'''<remarks></remarks>
Public Function CreateSimpleFillSymbol(ByVal fillColor As ESRI.ArcGIS.Display.IRgbColor, ByVal fillStyle As ESRI.ArcGIS.Display.esriSimpleFillStyle, ByVal borderColor As ESRI.ArcGIS.Display.IRgbColor, ByVal borderStyle As ESRI.ArcGIS.Display.esriSimpleLineStyle, ByVal borderWidth As System.Double) As ESRI.ArcGIS.Display.ISimpleFillSymbol

  If fillColor Is Nothing OrElse fillStyle=Nothing OrElse borderColor Is Nothing OrElse borderStyle=Nothing Then
    Return Nothing
  End If

  Dim simpleLineSymbol As ESRI.ArcGIS.Display.ISimpleLineSymbol=New ESRI.ArcGIS.Display.SimpleLineSymbolClass
  simpleLineSymbol.Width=borderWidth
  simpleLineSymbol.Color=borderColor
  simpleLineSymbol.Style=borderStyle

  Dim simpleFillSymbol As ESRI.ArcGIS.Display.ISimpleFillSymbol=New ESRI.ArcGIS.Display.SimpleFillSymbolClass
  simpleFillSymbol.Outline=simpleLineSymbol
  simpleFillSymbol.Style=fillStyle
  simpleFillSymbol.Color=fillColor

  Return simpleFillSymbol

End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.Display
  • ESRI.ArcGIS.System