windowsforms-devexpress-dot-xtraeditors-dot-svgimagebox-038e2938.md
Fires when the item selection is about to be changed. Allows you to cancel the current operation.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.Utils.v25.2.dll
NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core
public event SvgImageSelectionChangingEventHandler SelectionChanging
Public Event SelectionChanging As SvgImageSelectionChangingEventHandler
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. |
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.
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;
}
}
Private Sub SvgImageBox1_SelectionChanging(sender As Object, e As DevExpress.XtraEditors.SvgImageSelectionChangingEventArgs) Handles SvgImageBox1.SelectionChanging
'Prevent item selection from being cleared when a user clicks on the empty space
If e.Action = DevExpress.XtraEditors.SvgImageSelectionChangeAction.Clear Then
e.Cancel = True
Return
End If
'Prevent an item from being selected/deselected.
If e.Item.Equals(SvgImageBox1.HoveredItem) Then
e.Cancel = True
Return
End If
End Sub
See Also