Skip to main content

PopupMenuShowingEventArgs.HitInfo Property

Gets an object that identifies a clicked element.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v24.1.dll

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

Declaration

public GridHitInfo HitInfo { get; }

Property Value

Type Description
GridHitInfo

A GridHitInfo object or its descendant that identifies a clicked element.

Remarks

The HitInfo property allows you to determine the Grid’s visual element for which a popup menu will be displayed.

For instance, to check the type of the clicked element, use the HitTest property provided by the HitInfo object.

Refer to the following help topic for more information: Hit Information.

Example

The following code sample displays a context menu when a user right-clicks the Header Panel Button. The created context menu contains a Column Auto Width button. This menu item toggles the GridOptionsView.ColumnAutoWidth option.

GridView-Menu-For-Column-Header-Panel-Button

void gridView1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
    if (e.HitInfo.HitTest == GridHitTest.ColumnButton) {
        popupMenu_HeaderButton.Tag = e.HitInfo;
        e.ShowCustomMenu(popupMenu_HeaderButton);
    }
}
GridHitInfo GetHitInfo(BarItemLink link) {
    PopupMenu menu = link.LinkedObject as PopupMenu;
    return menu.Tag as GridHitInfo;
}
void barButtonItem_AutoWidth_ItemClick(object sender, ItemClickEventArgs e) {
    GridHitInfo info = GetHitInfo(e.Link);
    info.View.OptionsView.ColumnAutoWidth = !info.View.OptionsView.ColumnAutoWidth;
    if (info.View.OptionsView.ColumnAutoWidth == false)
        info.View.BestFitColumns();
}

Refer to the following help topic for more information: Custom Context Menus.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the HitInfo property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also