Skip to main content

Highlight and Select Items

  • 3 minutes to read

End users can highlight and select sunburst items. The Sunburst control provides an API that allows you to interact with the selected items in code.

Change the Highlight Mode

The SunburstControl.HighlightMode property specifies that elements are highlighted when the mouse pointer hovers over a sunburst item. The SunburstHighlightMode enumeration lists all the available modes:

Mode

Example

Description

Single

sunburst-highlight-mode-single

The item is highlighted when the mouse pointer hovers over it.

PathFromRoot (the default mode)

sunburst-highlight-mode-path-to-root

The item and all its parent items are highlighted when the mouse pointer hovers over it.

Use the SunburstControl.GetItemPath method to retrieve items that form the path from the top-level item to the specified item.

WholeGroup

sunburst-highlight-mode0whole-group

The item and its child items are highlighted when the mouse pointer hovers over it.

None

sunburst-highlight-mode-none

Elements are not highlighted when they are hovered.

The code below shows how to specify the highlight mode:

sunburstControl.HighlightMode = SunburstHighlightMode.WholeGroup;

Change the Selection Mode

The HierarchicalChartControlBase.SelectionMode property defines whether end users can select sunburst items. The ElementSelectionMode enumeration lists the available modes:

Mode

Example

Description

Single

sunburst-element-selection-mode-single

Only one element (item or group) can be selected.

Multiple

sunburst-element-selection-mode-multiple

Multiple items can be selected simultaneously.

Extended

sunburst-element-selection-mode-extended

The Extended mode combines the Single and Multiple selection modes’ behaviors.

  • Click an item to select it.
  • To select/deselect multiple items, click them while the Ctrl or Shift key is pressed.

None (the default mode)

An end user cannot select sunburst items.

The code below shows how to specify the selection mode:

sunburstControl.SelectionMode = ElementSelectionMode.Single;

Interact with the Selected Items in Code

You can handle the HierarchicalChartControlBase.SelectionChanged event to track whether the selected Sunburst item collection changed.

The following code shows how to use the selected items as a chart’s and grid’s data source:

void OnSunburstSelectionChanged(object sender, SelectionChangedEventArgs e) {
    chartControl.DataSource = null;
    gridControl.DataSource = null;
    IList selectedItems = e.SelectedItems as IList;
    if (selectedItems != null && selectedItems.Count > 0) {
        chartControl.DataSource = selectedItems;
        gridControl.DataSource = selectedItems;
    }
}

The code above uses the following API members:

Member Description
HierarchicalChartControlBase.SelectionChanged Occurs after the selected sunburst items’ collection changes.
SelectionChangedEventArgs Provides data for the HierarchicalChartControlBase.SelectionChanged event.
SelectionChangedEventArgs.SelectedItems Returns the selected items’ collection.

You can also use the HierarchicalChartControlBase.SelectedItems property to access the selected items’ collection.

If the Sunburst control is bound to data using its FlatDataAdapter or HierarchicalDataAdapter, the SelectedItems property returns the data source objects for the selected sunburst items. The SunburstItem.Tag property stores these data source objects.

If the Sunburst control uses ItemStorage, the SelectedItems property stores the selected sunburst items. Note that if the item’s Tag property is specified, the SelectedItems stores the Tag property values.