Back to Devexpress

DataViewBase.RowCellMenuCustomizations Property

wpf-devexpress-dot-xpf-dot-grid-dot-dataviewbase-6bf6c9c7.md

latest5.3 KB
Original Source

DataViewBase.RowCellMenuCustomizations Property

Allows you to customize the row cell‘s context menu. You can add new menu items or remove existing items.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
[Browsable(false)]
public BarManagerActionCollection RowCellMenuCustomizations { get; }
vb
<Browsable(False)>
Public ReadOnly Property RowCellMenuCustomizations As BarManagerActionCollection

Property Value

TypeDescription
BarManagerActionCollection

A collection of bar actions to customize the row cell‘s context menu.

|

Remarks

Refer to the Context Menus topic for more information.

Example

This example shows how to define a cell’s context menu. The context menu allows users to delete a row or copy its data to the clipboard.

View Example: Display a Context Menu for Data Cells

xaml
<dxg:GridControl.View>
    <dxg:TableView x:Name="view" AutoWidth="True">
        <dxg:TableView.RowCellMenuCustomizations>
            <dxb:BarButtonItem Name="deleteRowItem" Content="Delete"
                               IsEnabled="{Binding Row.Row.CanBeDeleted}"
                               ItemClick="OnDeleteRow"/>
            <dxb:BarButtonItem Name="copyCellDataItem" Content="Copy" 
                               ItemClick="OnCopyRow" />
        </dxg:TableView.RowCellMenuCustomizations>
    </dxg:TableView>
</dxg:GridControl.View>
cs
void OnCopyRow(object sender, ItemClickEventArgs e) {
    if (view.GridMenu.MenuInfo is GridCellMenuInfo menuInfo && menuInfo.Row != null)
        grid.CopyCurrentItemToClipboard();
}
void OnDeleteRow(object sender, ItemClickEventArgs e) {
    if (view.GridMenu.MenuInfo is GridCellMenuInfo menuInfo && menuInfo.Row != null)
        view.DeleteRow(menuInfo.Row.RowHandle.Value);
}
vb
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
        grid.CopyCurrentItemToClipboard()
    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

The following code snippets (auto-collected from DevExpress Examples) contain references to the RowCellMenuCustomizations 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.

how-to-access-and-remove-rows-by-using-a-custom-cells-context-menu-e1558/CS/Window1.xaml#L16

xml
<dxg:TableView x:Name="view" AutoWidth="True">
    <dxg:TableView.RowCellMenuCustomizations>
        <dxb:BarButtonItem Name="deleteRowItem" Content="Delete"

wpf-data-grid-add-and-remove-rows-in-code/CS/AddRemoveRows/MainWindow.xaml#L24

xml
<dxg:TableView AutoWidth="True">
    <dxg:TableView.RowCellMenuCustomizations>
        <dxb:BarButtonItem Content="Delete" Command="{x:Static dxg:GridCommands.DeleteFocusedRow}"/>

See Also

DataViewBase Class

DataViewBase Members

DevExpress.Xpf.Grid Namespace