Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 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

WinExplorerView.ContextButtonClick Event

Occurs when a context button in this WinExplorerView is clicked.

Namespace: DevExpress.XtraGrid.Views.WinExplorer

Assembly: DevExpress.XtraGrid.v24.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

#Declaration

[DXCategory("Context Buttons")]
public event ContextItemClickEventHandler ContextButtonClick

#Event Data

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

Property Description
DataItem Gets or sets an Object that contains a clicked ContextItem. This object is a control or a control’s item.
Item Gets a clicked ContextItem.
ItemInfo Gets or sets a clicked ContextItem‘s ContextItemViewInfo.
ScreenBounds Returns a Rectangle that contains a ContextItem.

#Remarks

Handling the ContextButtonClick event allows you to respond to an end-user clicking a context button stored within the WinExplorerView.ContextButtons collection. See the Context Buttons section of the WinExplorer View to learn more.

#Example

If the ShowCheckBoxes option is enabled, the view displays check boxes in each record (row). The CheckBoxColumn property specifies the data field (column) that contains values for the check boxes. The code below shows how to use context check buttons instead of check boxes in the view.

image

using DevExpress.Utils;
using DevExpress.XtraGrid.Views.WinExplorer;
using DevExpress.XtraGrid.Views.Base;

winExplorerView1.OptionsView.ShowCheckBoxes = false;

private void winExplorerView1_ContextButtonClick(object sender, ContextItemClickEventArgs e) {
    WinExplorerView view = sender as WinExplorerView;
    if (e.Item.Name == "itemCheck") {
        view.SetRowCellValue((int)e.DataItem, view.ColumnSet.CheckBoxColumn, ((CheckContextButton)e.Item).Checked);
    }
}

private void winExplorerView1_ContextButtonCustomize(object sender, WinExplorerViewContextButtonCustomizeEventArgs e) {
    WinExplorerView view = sender as WinExplorerView;
    if (e.Item.Name == "itemCheck") {
        ((CheckContextButton)(e.Item)).Checked = Convert.ToBoolean(view.GetRowCellValue(e.RowHandle, view.ColumnSet.CheckBoxColumn));
    }
}

private void winExplorerView1_CellValueChanged(object sender, CellValueChangedEventArgs e) {
    WinExplorerView view = sender as WinExplorerView;
    if (e.Column == view.ColumnSet.CheckBoxColumn) {
        view.RefreshContextButtons();
    }
}
See Also