Back to Devexpress

BaseListBoxControl.ContextButtonClick Event

windowsforms-devexpress-dot-xtraeditors-dot-baselistboxcontrol-1a9bbe9b.md

latest3.5 KB
Original Source

BaseListBoxControl.ContextButtonClick Event

Fires when a context button is clicked.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Behavior")]
public event ContextItemClickEventHandler ContextButtonClick
vb
<DXCategory("Behavior")>
Public Event ContextButtonClick As ContextItemClickEventHandler

Event Data

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

PropertyDescription
DataItemGets or sets an Object that contains a clicked ContextItem. This object is a control or a control’s item.
ItemGets a clicked ContextItem.
ItemInfoGets or sets a clicked ContextItem‘s ContextItemViewInfo.
ScreenBoundsReturns a Rectangle that contains a ContextItem.

Remarks

The ContextButtonClick event fires when an end-user clicks any context button (see BaseListBoxControl.ContextButtons). The ContextItemClickEventArgs.Item property allows you to determine the button being clicked.

You can also handle the ContextItem.Click event to respond to a click on a particular button.

Example

csharp
private void listBoxControl_ContextButtonClick(object sender, DevExpress.Utils.ContextItemClickEventArgs e) {
    if (e.Item.Name=="Delete") {
        var listBoxControl = (DevExpress.XtraEditors.ListBoxControl)sender;
        listBoxControl.Items.Remove(e.DataItem);                
    }            
}
vb
Private Sub listBoxControl_ContextButtonClick(ByVal sender As Object, ByVal e As DevExpress.Utils.ContextItemClickEventArgs)
    If e.Item.Name="Delete" Then
       Dim listBoxControl = DirectCast(sender, DevExpress.XtraEditors.ListBoxControl)
       listBoxControl.Items.Remove(e.DataItem)
    End If
End Sub

See Also

ContextButtons

ContextButtonValueChanged

Click

BaseListBoxControl Class

BaseListBoxControl Members

DevExpress.XtraEditors Namespace