Skip to main content
All docs
V23.2

LegendBase.HorizontalAlignment Property

Gets or sets the legend’s horizontal alignment in the control.

Namespace: DevExpress.XtraTreeMap

Assembly: DevExpress.XtraTreeMap.v23.2.dll

NuGet Package: DevExpress.TreeMap

Declaration

[XtraSerializableProperty]
public LegendHorizontalAlignment HorizontalAlignment { get; set; }

Property Value

Type Description
LegendHorizontalAlignment

A value that specifies the horizontal alignment within the control.

Available values:

Name Description Image
LeftOutside

The legend is positioned to the left of the chart.

Legend horizontal alignment - LeftOutside

Left

The legend’s left edge is aligned with the chart’s left edge.

Legend horizontal alignment - Left

Center

Centers a legend horizontally in the chart.

Legend horizontal alignment - Center

Right

The legend’s right edge is aligned with the chart’s right edge.

Legend horizontal alignment - Right

RightOutside

The legend is positioned to the right of the chart.

Legend horizontal alignment - RightOutside

Example

How to Add a Legend to a Treemap

This example adds a legend to a treemap and configures its title, border, and text settings.

Treemap legend

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.Font = new Font("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;
    }
See Also