Skip to main content
A newer version of this page is available. .

GridViewBase.GridMenu Property

Gets the context menu that is displayed within a View.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v20.2.dll

NuGet Packages: DevExpress.WindowsDesktop.Wpf.Grid.Core, DevExpress.Wpf.Grid.Core

Declaration

public GridPopupMenu GridMenu { get; }

Property Value

Type Description
GridPopupMenu

The context menu displayed within a View. null if no menu is displayed within a View.

Remarks

Refer to the Context Menus topic for more information.

Example

The following example shows how to create a context menu that allows users to copy a cell’s data and remove rows:

View Example

<dxg:TableView x:Name="view" AutoWidth="True">
    <dxg:TableView.RowCellMenuCustomizations>
        <dxb:BarButtonItem Name="deleteRowItem" Content="Delete" ItemClick="deleteRowItem_ItemClick" />
        <dxb:BarButtonItem Name="copyCellDataItem" Content="Copy Cell Data" ItemClick="copyCellDataItem_ItemClick" />
    </dxg:TableView.RowCellMenuCustomizations>
</dxg:TableView>
Private Sub copyCellDataItem_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
    Dim menuInfo As GridCellMenuInfo = TryCast(view.GridMenu.MenuInfo, GridCellMenuInfo)
    If menuInfo IsNot Nothing AndAlso menuInfo.Row IsNot Nothing Then
        Dim text As String = "" & grid.GetCellValue(menuInfo.Row.RowHandle.Value, TryCast(menuInfo.Column, GridColumn)).ToString()
        Clipboard.SetText(text)
    End If
End Sub

Private Sub deleteRowItem_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
    Dim menuInfo As GridCellMenuInfo = TryCast(view.GridMenu.MenuInfo, GridCellMenuInfo)
    If menuInfo IsNot Nothing AndAlso menuInfo.Row IsNot Nothing Then
        view.DeleteRow(menuInfo.Row.RowHandle.Value)
    End If
End Sub
See Also