ColorListLegend.SortOrder Property
Gets or sets the sort order of the color list legend items.
Namespace: DevExpress.XtraMap
Assembly: DevExpress.XtraMap.v18.2.dll
Declaration
[DefaultValue(LegendItemsSortOrder.Descending)]
public LegendItemsSortOrder SortOrder { get; set; }
Property Value
Type | Default | Description |
---|---|---|
LegendItemsSortOrder | **Descending** | A LegendItemsSortOrder enumeration value, specifying the color list items sort order. |
Available values:
Name | Description |
---|---|
Ascending | Specifies an ascending sorting order. It means that the first added item will be at top of the legend. |
Descending | Specifies a descending sorting order. It means that the last added item will be at top of the legend. |
Example
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-change-an-order-of-color-list-legend-items-t202594
using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraMap;
namespace ColorListLegend_SortOrder {
public partial class Form1 : Form {
ColorListLegend legend;
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
legend = new ColorListLegend() { Alignment = LegendAlignment.TopRight };
legend.CustomItems.Add(new ColorLegendItem() {
Color = Color.Orange,
Text = "First color"
});
legend.CustomItems.Add(new ColorLegendItem() {
Color = Color.LightGray,
Text = "Second color"
});
legend.CustomItems.Add(new ColorLegendItem() {
Color = Color.Coral,
Text = "Third color"
});
mapControl.Legends.Add(legend);
lbSortOrder.DataSource = Enum.GetValues(typeof(LegendItemsSortOrder));
}
private void lbSortOrder_SelectedIndexChanged(object sender, EventArgs e) {
legend.SortOrder = (LegendItemsSortOrder)lbSortOrder.SelectedValue;
}
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SortOrder 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.