Back to Devexpress

LineStyle.DashStyle Property

corelibraries-devexpress-dot-xtracharts-dot-linestyle-33aabac9.md

latest9.3 KB
Original Source

LineStyle.DashStyle Property

Gets or sets the dash style used to paint the line.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public DashStyle DashStyle { get; set; }
vb
Public Property DashStyle As DashStyle

Property Value

TypeDescription
DashStyle

A DashStyle enumeration that represents the style used to paint the line.

|

Available values:

NameDescription
Empty

Specifies that an element’s should be filled using the current appearance settings.

| | Solid |

Specifies a solid line.

| | Dash |

Specifies a line consisting of dashes.

| | Dot |

Specifies a line consisting of dots.

| | DashDot |

Specifies a line consisting of a repeating pattern of dash-dot.

| | DashDotDot |

Specifies a line consisting of a repeating pattern of dash-dot-dot.

|

Example

This example demonstrates how the grid lines and tickmarks of an axis can be customized at runtime.

To access an axis, you should cast your chart’s diagram object to the required diagram type. Then, use the Axis2D.Tickmarks and AxisBase.GridLines properties to access the corresponding elements. To define the number of minor tickmarks (grid lines), use the AxisBase.MinorCount property.

csharp
// Cast the chart's diagram to the XYDiagram type, to access its axes.
XYDiagram diagram = (XYDiagram)chartControl1.Diagram;

// Customize the appearance of the axes' tickmarks.
diagram.AxisX.Tickmarks.CrossAxis = true;
diagram.AxisX.Tickmarks.Length = 5;
diagram.AxisX.Tickmarks.Thickness = 2;

diagram.AxisY.Tickmarks.Visible = false;
diagram.AxisY.Tickmarks.MinorVisible = false;

diagram.AxisX.Tickmarks.MinorLength = 3;
diagram.AxisX.Tickmarks.MinorThickness = 1;

diagram.AxisX.MinorCount = 2;
diagram.AxisY.MinorCount = 4;

// Customize the appearance of the axes' grid lines.
diagram.AxisX.GridLines.Visible = false;
diagram.AxisX.GridLines.MinorVisible = false;

diagram.AxisY.GridLines.Visible = true;
diagram.AxisY.GridLines.MinorVisible = true;

diagram.AxisY.GridLines.Color = Color.Red;
diagram.AxisY.GridLines.LineStyle.DashStyle = DashStyle.Solid;
diagram.AxisY.GridLines.LineStyle.Thickness = 2;

diagram.AxisY.GridLines.MinorColor = Color.Blue;
diagram.AxisY.GridLines.MinorLineStyle.DashStyle = DashStyle.Dash;
diagram.AxisY.GridLines.MinorLineStyle.Thickness = 1;
vb
' Cast the chart's diagram to the XYDiagram type, to access its axes.
Dim diagram As XYDiagram = CType(chartControl1.Diagram, XYDiagram)

' Customize the appearance of the axes' tickmarks.
diagram.AxisX.Tickmarks.CrossAxis = True
diagram.AxisX.Tickmarks.Length = 5
diagram.AxisX.Tickmarks.Thickness = 2

diagram.AxisY.Tickmarks.Visible = False
diagram.AxisY.Tickmarks.MinorVisible = False

diagram.AxisX.Tickmarks.MinorLength = 3
diagram.AxisX.Tickmarks.MinorThickness = 1

diagram.AxisX.MinorCount = 2
diagram.AxisY.MinorCount = 4

' Customize the appearance of the axes' grid lines.
diagram.AxisX.GridLines.Visible = False
diagram.AxisX.GridLines.MinorVisible = False

diagram.AxisY.GridLines.Visible = True
diagram.AxisY.GridLines.MinorVisible = True

diagram.AxisY.GridLines.Color = Color.Red
diagram.AxisY.GridLines.LineStyle.DashStyle = DashStyle.Solid
diagram.AxisY.GridLines.LineStyle.Thickness = 2

diagram.AxisY.GridLines.MinorColor = Color.Blue
diagram.AxisY.GridLines.MinorLineStyle.DashStyle = DashStyle.Dash
diagram.AxisY.GridLines.MinorLineStyle.Thickness = 1

The following code snippets (auto-collected from DevExpress Examples) contain references to the DashStyle property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

dashboard-constant-lines/CS/ConstantLineExtension.Win/ConstantLineModule.cs#L79

csharp
line.Title.Text = customConstantLine.LabelText;
line.LineStyle.DashStyle = DashStyle.Dash;
line.LineStyle.Thickness = 2;

winforms-chart-draw-a-crosshair-cursor/CS/CustomDrawCrosshairCursor/Form1.cs#L22

csharp
e.CrosshairLineElement.Color = Color.Green;
e.CrosshairLineElement.LineStyle.DashStyle = DashStyle.DashDot;
e.CrosshairLineElement.LineStyle.Thickness = 3;

wpf-dashboard-custom-properties/CS/Wpf-Dashboard-Custom-Properties/Modules/ChartItemModule/ChartOptions/LineStyle.cs#L66

csharp
if(view != null)
        view.LineStyle.DashStyle = dashStyle;
}

winforms-dashboard-custom-properties/CS/WinForms-Dashboard-Custom-Properties/Modules/ConstantLineUserValueModule.cs#L98

csharp
line.LineStyle.Thickness = 2;
line.LineStyle.DashStyle = DashStyle.Dash;
line.Title.Text = "Value: " + moduleData.Value.ToString();

asp-net-web-forms-dashboard-custom-properties-sample/CS/WebFormsDashboardCustomPropertiesSample/Export/ChartConstantLinesExtension.cs#L43

csharp
line.Title.Text = customConstantLine.labelText;
line.LineStyle.DashStyle = DashStyle.Dash;
line.LineStyle.Thickness = 2;

winforms-chart-draw-a-crosshair-cursor/VB/CustomDrawCrosshairCursor/Form1.vb#L27

vb
e.CrosshairLineElement.Color = Color.Green
e.CrosshairLineElement.LineStyle.DashStyle = DashStyle.DashDot
e.CrosshairLineElement.LineStyle.Thickness = 3

wpf-dashboard-custom-properties/VB/Wpf-Dashboard-Custom-Properties/Modules/ChartItemModule/ChartOptions/LineStyle.vb#L66

vb
If view IsNot Nothing Then
    view.LineStyle.DashStyle = dashStyle
End If

winforms-dashboard-custom-properties/VB/WinForms-Dashboard-Custom-Properties/Modules/ConstantLineUserValueModule.vb#L104

vb
line.LineStyle.Thickness = 2
line.LineStyle.DashStyle = DashStyle.Dash
line.Title.Text = "Value: " & moduleData.Value.ToString()

asp-net-web-forms-dashboard-custom-properties-sample/VB/WebFormsDashboardCustomPropertiesSample/Export/ChartConstantLinesExtension.vb#L41

vb
line.Title.Text = customConstantLine.labelText
line.LineStyle.DashStyle = DashStyle.Dash
line.LineStyle.Thickness = 2

winforms-chart-create-and-customize-a-constant-line/VB/ConstLines/Form1.vb#L52

vb
constantLine1.Color = Color.Red
constantLine1.LineStyle.DashStyle = DashStyle.Dash
constantLine1.LineStyle.Thickness = 2

See Also

LineStyle Class

LineStyle Members

DevExpress.XtraCharts Namespace