windowsforms-devexpress-dot-xtratreemap-dot-legendbase-ba13095f.md
Gets or sets the direction in which items are positioned in the legend.
Namespace : DevExpress.XtraTreeMap
Assembly : DevExpress.XtraTreeMap.v25.2.dll
NuGet Package : DevExpress.TreeMap
[XtraSerializableProperty]
public LegendDirection Direction { get; set; }
<XtraSerializableProperty>
Public Property Direction As LegendDirection
| Type | Description |
|---|---|
| LegendDirection |
The direction in which items are positioned in the legend.
|
Available values:
| Name | Description |
|---|---|
| TopToBottom |
Legend items are positioned vertically from the top to the bottom of the legend.
| | BottomToTop |
Legend items are positioned vertically from the bottom to the top of the legend.
| | LeftToRight |
Legend items are positioned horizontally from the left to the right of the legend.
| | RightToLeft |
Legend items are positioned horizontally from the right to the left of the legend.
|
This example adds a legend to a treemap and configures its title, border, and text settings.
Create a ColorListLegend object.
Use the LegendBase.Title property to access the legend title settings. Specify the following title options:
Configure the options below to customize the position and alignment of the legend and legend items:
The following properties allow you to customize the legend border’s color and width:
Use the treemap’s Legend property to assign the legend to the treemap.
using DevExpress.XtraTreeMap;
using System;
using System.Drawing;
using System.Windows.Forms;
//...
private void Form1_Load(object sender, EventArgs e) {
//...
// Create a legend.
ColorListLegend legend = new ColorListLegend();
// Specify the legend title, and the title's color and font.
legend.Title.Text = "Field of Activity";
legend.Title.TextColor = Color.Black;
legend.Title.DXFont = new DXFont("Tahoma", 10);
// Define the color for legend items.
legend.TextColor = Color.Black;
// Set the offset beween an item's marker and text.
legend.TextOffset = 16;
// Specify the legend alignment and position.
legend.Direction = LegendDirection.LeftToRight;
legend.HorizontalAlignment = LegendHorizontalAlignment.Center;
legend.VerticalAlignment = LegendVerticalAlignment.BottomOutside;
// Define whether to arrange items in left-aligned columns.
legend.EquallySpacedItems = true;
// Configure the border color and width.
legend.BorderColor = Color.LightGray;
legend.BorderWidth = 1;
// Assign the legend to the treemap.
treeMapControl1.Legend = legend;
}
Imports DevExpress.XtraTreeMap
Imports System
Imports System.Drawing
Imports System.Windows.Forms
'...
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
'...
' Create a legend.
Dim legend As ColorListLegend = New ColorListLegend()
' Specify the legend title, and the title's color and font.
legend.Title.Text = "Field of Activity"
legend.Title.TextColor = Color.Black
legend.Title.DXFont = New DXFont("Tahoma", 10)
' Define the color for legend items.
legend.TextColor = Color.Black
' Set the offset beween an item's marker and text.
legend.TextOffset = 16
' Specify the legend alignment and position.
legend.Direction = LegendDirection.LeftToRight
legend.HorizontalAlignment = LegendHorizontalAlignment.Center
legend.VerticalAlignment = LegendVerticalAlignment.BottomOutside
' Define whether to arrange items in left-aligned columns.
legend.EquallySpacedItems = True
' Configure the border color and width.
legend.BorderColor = Color.LightGray
legend.BorderWidth = 1
' Assign the legend to the treemap.
treeMapControl1.Legend = legend
End Sub
See Also