Back to Devexpress

TextElement.Text Property

windowsforms-devexpress-dot-xtratreemap-dot-textelement-16a5eb58.md

latest5.9 KB
Original Source

TextElement.Text Property

Gets or sets the element’s text.

Namespace : DevExpress.XtraTreeMap

Assembly : DevExpress.XtraTreeMap.v25.2.dll

NuGet Package : DevExpress.TreeMap

Declaration

csharp
[XtraSerializableProperty]
public string Text { get; set; }
vb
<XtraSerializableProperty>
Public Property Text As String

Property Value

TypeDescription
String

A string value that specifies the element text.

|

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.

  • 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.

  • C#

  • VB.NET

csharp
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;
    }
vb
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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Text 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.

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/SunburstChart/SunburstItemControlProvider.cs#L73

csharp
if(Interactivity.IsDrillDownEnabled) {
    emptyTitle.Text = "The Sunburst Item does not support Drill-Down";
    emptyTitle.Visible = true;

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/SunburstChart/SunburstItemControlProvider.vb#L84

vb
If Interactivity.IsDrillDownEnabled Then
    emptyTitle.Text = "The Sunburst Item does not support Drill-Down"
    emptyTitle.Visible = True

See Also

TextElement Class

TextElement Members

DevExpress.XtraTreeMap Namespace