ArcObjects Library Reference

Create Line Fill Symbol Snippet

Create a default Line Fill Symbol by supplying an RgbColor and line width.

[C#]

///<summary>Create a default Line Fill Symbol by supplying an RgbColor and line width.</summary>
///  
///<param name="rgbColor">An IRgbColor interface that is the color of the line fill symbol.</param>
///<param name="width">A System.Double that is the thickness of the line fill symbol. Example: 2.0</param>
///   
///<returns>An ILineFillSymbol interface.</returns>
///   
///<remarks></remarks>
public ESRI.ArcGIS.Display.ILineFillSymbol CreateLineFillSymbol(ESRI.ArcGIS.Display.IRgbColor rgbColor, System.Double width)
{
  
  if(rgbColor == null)
  {
    return null;
  }
  // Create the Line Symbol to be used
  ESRI.ArcGIS.Display.ICartographicLineSymbol cartographicLineSymbol = new ESRI.ArcGIS.Display.CartographicLineSymbolClass();
  cartographicLineSymbol.Cap = ESRI.ArcGIS.Display.esriLineCapStyle.esriLCSButt;
  cartographicLineSymbol.Join = ESRI.ArcGIS.Display.esriLineJoinStyle.esriLJSMitre;
  cartographicLineSymbol.Color = rgbColor;
  cartographicLineSymbol.Width = width;

  // Create the LineFillSymbol
  ESRI.ArcGIS.Display.ILineFillSymbol lineFillSymbol = new ESRI.ArcGIS.Display.LineFillSymbolClass();
  lineFillSymbol.Angle = 45;
  lineFillSymbol.Separation = 10;
  lineFillSymbol.Offset = 5;

  lineFillSymbol.LineSymbol = cartographicLineSymbol;

  return lineFillSymbol;
}
[Visual Basic .NET]

'''<summary>Create a default Line Fill Symbol by supplying an RgbColor and line width.</summary>
'''  
'''<param name="rgbColor">An IRgbColor interface that is the color of the line fill symbol.</param>
'''<param name="width">A System.Double that is the thickness of the line fill symbol. Example: 2.0</param>
'''   
'''<returns>An ILineFillSymbol interface.</returns>
'''   
'''<remarks></remarks>
Public Function CreateLineFillSymbol(ByVal rgbColor As ESRI.ArcGIS.Display.IRgbColor, ByVal width As System.Double) As ESRI.ArcGIS.Display.ILineFillSymbol

  If rgbColor Is Nothing Then
    Return Nothing
  End If

  ' Create the Line Symbol to be used
  Dim cartographicLineSymbol As ESRI.ArcGIS.Display.ICartographicLineSymbol = New ESRI.ArcGIS.Display.CartographicLineSymbolClass
  With cartographicLineSymbol
    .Cap = ESRI.ArcGIS.Display.esriLineCapStyle.esriLCSButt
    .Join = ESRI.ArcGIS.Display.esriLineJoinStyle.esriLJSMitre
    .Color = rgbColor
    .Width = width
  End With

  ' Create the LineFillSymbol
  Dim lineFillSymbol As ESRI.ArcGIS.Display.ILineFillSymbol = New ESRI.ArcGIS.Display.LineFillSymbolClass
  With lineFillSymbol
    .Angle = 45
    .Separation = 10
    .Offset = 5
  End With

  lineFillSymbol.LineSymbol = cartographicLineSymbol

  Return lineFillSymbol

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