Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

    Take the survey Not interested

    SvgImageBox.SelectionChanging Event

    Fires when the item selection is about to be changed. Allows you to cancel the current operation.

    Namespace: DevExpress.XtraEditors

    Assembly: DevExpress.Utils.v25.1.dll

    NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

    #Declaration

    public event SvgImageSelectionChangingEventHandler SelectionChanging

    #Event Data

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

    Property Description
    Action Gets or sets how the selected item collection has been changed.
    Cancel Gets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.
    Item Gets or sets the currently processed item.

    #Remarks

    The event’s Item parameter specifies the item whose selected state is about to be changed. Use the Action parameter to identify the item’s new state.

    If all items are deselected at once (the SvgImageBox.Selection collection is cleared), the Item parameter returns null and the Action parameter returns Clear.

    To prevent an item’s selected state from being changed, set the event’s Cancel parameter to true.

    #Example

    This example shows how to handle the SelectionChanging event to prevent the current selection from being changed.

    private void svgImageBox1_SelectionChanging(object sender, DevExpress.XtraEditors.SvgImageSelectionChangingEventArgs e) {
        //Prevent item selection from being cleared when a user clicks on the empty space
        if (e.Action == DevExpress.XtraEditors.SvgImageSelectionChangeAction.Clear) {
            e.Cancel = true;
            return;
        }
    
        //Prevent an item from being selected/deselected.
        if (e.Item == svgImageBox1.HoveredItem) {
            e.Cancel = true;
            return;
        }
    }
    
    See Also