Back to Devexpress

SankeyDiagramControl.SelectedItemsChanged Event

windowsforms-devexpress-dot-xtracharts-dot-sankey-dot-sankeydiagramcontrol-388c118f.md

latest5.2 KB
Original Source

SankeyDiagramControl.SelectedItemsChanged Event

Occurs after a user changes the Sankey selection state and this change is applied to the SelectedItems collection.

Namespace : DevExpress.XtraCharts.Sankey

Assembly : DevExpress.XtraCharts.v25.2.UI.dll

NuGet Package : DevExpress.Win.Charts

Declaration

csharp
public event SankeySelectedItemsChangedEventHandler SelectedItemsChanged
vb
Public Event SelectedItemsChanged As SankeySelectedItemsChangedEventHandler

Event Data

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

PropertyDescription
SelectedLinksReturns selected Sankey links.
SelectedNodesReturns selected Sankey nodes.

Remarks

The following example uses the SankeySelectedItemsChangedEventArgs.SelectedLinks property to add selected links to a custom selectedExportItems collection:

csharp
HashSet<ExportItem> selectedExportItems = new HashSet<ExportItem>();

private void sankeyDiagramControl1_SelectedItemsChanged(object sender, SankeySelectedItemsChangedEventArgs e){
    selectedExportItems.Clear();
    foreach (SankeyLink link in e.SelectedLinks) {
        selectedExportItems.Add((ExportItem)link.Tags[0]);
    }
}

//...

public class ExportItem {
    public string Exporter { get; set; }
    public string Importer { get; set; }
    public double Sum { get; set; }

    public ExportItem(string from, string to, double weight) {
        this.Exporter = from;
        this.Importer = to;
        this.Sum = weight;
    }
}
vb
Private selectedExportItems As HashSet(Of ExportItem) = New HashSet(Of ExportItem)()

Private Sub sankeyDiagramControl1_SelectedItemsChanged(ByVal sender As Object, ByVal e As SankeySelectedItemsChangedEventArgs)
    selectedExportItems.Clear()

    For Each link As SankeyLink In e.SelectedLinks
        selectedExportItems.Add(CType(link.Tags(0), ExportItem))
    Next
End Sub

'...

Public Class ExportItem
    Public Property Exporter As String
    Public Property Importer As String
    Public Property Sum As Double

    Public Sub New(ByVal from As String, ByVal [to] As String, ByVal weight As Double)
        Exporter = from
        Importer = [to]
        Sum = weight
    End Sub
End Class

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SelectedItemsChanged event.

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/SankeyChart/SankeyItemControlProvider.cs#L29

csharp
sankey.EmptySankeyText.Text = string.Empty;
sankey.SelectedItemsChanged += Sankey_SelectedItemsChanged;
toolTipController = new ToolTipController();

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/SankeyChart/SankeyItemControlProvider.vb#L35

vb
sankey.EmptySankeyText.Text = String.Empty
AddHandler sankey.SelectedItemsChanged, AddressOf Sankey_SelectedItemsChanged
toolTipController = New ToolTipController()

See Also

SelectedItemsChanging

SelectedItems

SankeyDiagramControl Class

SankeyDiagramControl Members

DevExpress.XtraCharts.Sankey Namespace