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


Create Simple Line Symbol Snippet (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference

Create Simple Line Symbol Snippet

Create a simple line symbol by specifying a color, width and line style.

[C#]
///<summary>Create a simple line symbol by specifying a color, width and line style.</summary>
///  
///<param name="rgbColor">An IRGBColor interface.</param>
///<param name="inWidth">A System.Double that is the width of the line symbol in points. Example: 2</param>
///<param name="inStyle">An esriSimpleLineStyle enumeration. Example: esriSLSSolid.</param>
///   
///<returns>An ISimpleLineSymbol interface.</returns>
///  
///<remarks></remarks>
public ESRI.ArcGIS.Display.ISimpleLineSymbol CreateSimpleLineSymbol(ESRI.ArcGIS.Display.IRgbColor rgbColor, System.Double inWidth, ESRI.ArcGIS.Display.esriSimpleLineStyle inStyle)
{
  if(rgbColor == null)
  {
    return null;
  }
  
  ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol=new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
  simpleLineSymbol.Style=inStyle;
  simpleLineSymbol.Color=rgbColor;
  simpleLineSymbol.Width=inWidth;
  
  return simpleLineSymbol;
}
[Visual Basic .NET]
'''<summary>Create a simple line symbol by specifying a color, width and line style.</summary>
'''  
'''<param name="rgbColor">An IRGBColor interface.</param>
'''<param name="inWidth">A System.Double that is the width of the line symbol in points. Example: 2</param>
'''<param name="inStyle">An esriSimpleLineStyle enumeration. Example: esriSLSSolid.</param>
'''   
'''<returns>An ISimpleLineSymbol interface.</returns>
'''  
'''<remarks></remarks>
Public Function CreateSimpleLineSymbol(ByVal rgbColor As ESRI.ArcGIS.Display.IRgbColor, ByVal inWidth As System.Double, ByVal inStyle As ESRI.ArcGIS.Display.esriSimpleLineStyle) As ESRI.ArcGIS.Display.ISimpleLineSymbol

  If rgbColor Is Nothing Then
    Return Nothing
  End If

  Dim simpleLineSymbol As ESRI.ArcGIS.Display.ISimpleLineSymbol=New ESRI.ArcGIS.Display.SimpleLineSymbolClass
  simpleLineSymbol.Style=inStyle
  simpleLineSymbol.Color=rgbColor
  simpleLineSymbol.Width=inWidth

  Return simpleLineSymbol

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