Skip to main content
All docs
V24.1

HeatmapControl.SelectedItemsChanged Event

Occurs after the heatmap’s collection of selected items is changed.

Namespace: DevExpress.XtraCharts.Heatmap

Assembly: DevExpress.XtraCharts.v24.1.UI.dll

NuGet Package: DevExpress.Win.Charts

Declaration

public event SelectedItemsChangedEventHandler SelectedItemsChanged

Event Data

The SelectedItemsChanged event's data class is SelectedItemsChangedEventArgs. The following properties provide information specific to this event:

Property Description
Action Gets an action which describes how the collection has been changed.
NewItems Provides access to a collection of new selected chart elements (series and series points) and business data objects if a Chart Control or a series is bound to a data source.
OldItems Provides access to previously selected chart elements (series and series points) and business data objects if a Chart Control or a series is bound to a data source.

Remarks

The Heatmap Control stores selected cells in the HeatmapControl.SelectedItems collection. When a user clicks a cell, it (or the underlying data source object) is added to the collection and the SelectedItemsChanged event occurs. The SelectedItemsChanged event also occurs when a cell is deselected.

Example

The following example shows how to use heatmap selected cell data as a source for another chart:

Selection demo

Run Demo: Selection

public HeatmapSelection() {
    InitializeComponent();
    List<ProductSale> data = LoadData();
    HeatmapDataAdapter.DataSource = data;
    HeatmapDataAdapter.XArgumentComparer = new OriginalOrderComparer();
    heatmapControl1.SelectedItems.Add(data[0]);
}
List<ProductSale> LoadData() {
    List<ProductSale> data = new List<ProductSale>();
    try {
        XDocument sales_xml = XDocument.Load(Utils.GetRelativePath("ProductSales.xml"));
        foreach (XElement monthSale in sales_xml.Root.Elements()) {
            string product = monthSale.Element("Product").Value;
            string month = monthSale.Element("Month").Value;
            List<DailySale> dailySales = new List<DailySale>();
            foreach (XElement daySale in monthSale.Elements("SalesByDay").Elements("DailySale")) {
                dailySales.Add(new DailySale() {
                    Product = product,
                    Date = Convert.ToDateTime(daySale.Element("Date").Value),
                    Revenue = Convert.ToDouble(daySale.Element("Revenue").Value)
                });
            }
            data.Add(new ProductSale() { SalesByDay = dailySales });
        }
    }
    catch {
    }
    return data;
}
void heatmapControl1_SelectedItemsChanged(object sender, XtraCharts.SelectedItemsChangedEventArgs e) {
    List<DailySale> list = new List<DailySale>();
    foreach (ProductSale item in heatmapControl1.SelectedItems)
        list.AddRange(item.SalesByDay);
    chartControl1.DataSource = list;
}
See Also