windowsforms-devexpress-dot-xtratreemap-dot-treemapcontrol-77157043.md
Gets or sets a layout algorithm for arranging TreeMap items.
Namespace : DevExpress.XtraTreeMap
Assembly : DevExpress.XtraTreeMap.v25.2.UI.dll
NuGet Package : DevExpress.Win.TreeMap
[XtraSerializableProperty(XtraSerializationVisibility.Hidden)]
public ITreeMapLayoutAlgorithm LayoutAlgorithm { get; set; }
<XtraSerializableProperty(XtraSerializationVisibility.Hidden)>
Public Property LayoutAlgorithm As ITreeMapLayoutAlgorithm
| Type | Description |
|---|---|
| ITreeMapLayoutAlgorithm |
An object of a class implementing the ITreeMapLayoutAlgorithm interface.
|
To change the layout algorithm used by TreeMapControl, specify the TreeMapControl.LayoutAlgorithm property. For all default algorithms, you can configure the fill direction using the TreeMapLayoutAlgorithmBase.Direction.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LayoutAlgorithmCustomization {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using DevExpress.XtraTreeMap;
using System;
using System.Windows.Forms;
namespace LayoutAlgorithmCustomization {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
InitializeLayoutAlgorithmListBox();
InitializeLayoutDirectionListBox();
}
private void InitializeLayoutAlgorithmListBox() {
lbLayoutAlgorithm.DataSource = new ITreeMapLayoutAlgorithm[] {
new TreeMapSliceAndDiceLayoutAlgorithm(),
new TreeMapSquarifiedLayoutAlgorithm(),
new TreeMapStripedLayoutAlgorithm()
};
}
private void InitializeLayoutDirectionListBox() {
lbLayoutDirection.DataSource = Enum.GetValues(typeof(TreeMapLayoutDirection));
}
private void SetLayoutAlgorithm() {
if(lbLayoutAlgorithm.SelectedValue == null) return;
treeMap.LayoutAlgorithm = lbLayoutAlgorithm.SelectedValue as ITreeMapLayoutAlgorithm;
}
private void SetLayoutDirection() {
if(lbLayoutDirection.SelectedValue == null) return;
TreeMapLayoutAlgorithmBase layoutAlgorithm = treeMap.LayoutAlgorithm as TreeMapLayoutAlgorithmBase;
layoutAlgorithm.Direction = (TreeMapLayoutDirection)lbLayoutDirection.SelectedValue;
}
private void lbLayoutAlgorithm_SelectedIndexChanged(object sender, EventArgs e) {
SetLayoutAlgorithm();
SetLayoutDirection();
}
private void lbLayoutDirection_SelectedIndexChanged(object sender, EventArgs e) {
SetLayoutDirection();
}
}
}
Imports DevExpress.XtraTreeMap
Imports System
Imports System.Windows.Forms
Namespace LayoutAlgorithmCustomization
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
InitializeLayoutAlgorithmListBox()
InitializeLayoutDirectionListBox()
End Sub
Private Sub InitializeLayoutAlgorithmListBox()
lbLayoutAlgorithm.DataSource = New ITreeMapLayoutAlgorithm() { _
New TreeMapSliceAndDiceLayoutAlgorithm(), _
New TreeMapSquarifiedLayoutAlgorithm(), _
New TreeMapStripedLayoutAlgorithm() _
}
End Sub
Private Sub InitializeLayoutDirectionListBox()
lbLayoutDirection.DataSource = System.Enum.GetValues(GetType(TreeMapLayoutDirection))
End Sub
Private Sub SetLayoutAlgorithm()
If lbLayoutAlgorithm.SelectedValue Is Nothing Then
Return
End If
treeMap.LayoutAlgorithm = TryCast(lbLayoutAlgorithm.SelectedValue, ITreeMapLayoutAlgorithm)
End Sub
Private Sub SetLayoutDirection()
If lbLayoutDirection.SelectedValue Is Nothing Then
Return
End If
Dim layoutAlgorithm As TreeMapLayoutAlgorithmBase = TryCast(treeMap.LayoutAlgorithm, TreeMapLayoutAlgorithmBase)
layoutAlgorithm.Direction = CType(lbLayoutDirection.SelectedValue, TreeMapLayoutDirection)
End Sub
Private Sub lbLayoutAlgorithm_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lbLayoutAlgorithm.SelectedIndexChanged
SetLayoutAlgorithm()
SetLayoutDirection()
End Sub
Private Sub lbLayoutDirection_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lbLayoutDirection.SelectedIndexChanged
SetLayoutDirection()
End Sub
End Class
End Namespace
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Threading.Tasks
Imports System.Windows.Forms
Namespace LayoutAlgorithmCustomization
Friend NotInheritable Class Program
Private Sub New()
End Sub
''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread> _
Shared Sub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub
End Class
End Namespace
See Also