Back to Devexpress

PropertyGridControl.RowBrickMenuShowing Event

windowsforms-devexpress-dot-xtraverticalgrid-dot-propertygridcontrol-f6e01373.md

latest7.0 KB
Original Source

PropertyGridControl.RowBrickMenuShowing Event

Allows you to populate a context menu invoked with a click on a brick button (the Office view only).

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

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

Declaration

csharp
public event PopupMenuShowingEventHandler RowBrickMenuShowing
vb
Public Event RowBrickMenuShowing As PopupMenuShowingEventHandler

Event Data

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

PropertyDescription
AllowGets or sets whether to display the context menu. Inherited from BasePopupMenuShowingEventArgs.
HitInfoTypeIdentifies a grid element located under the popup menu.
InRecordHeaderGets whether the menu is displayed within a record header.
InRowGets whether the menu is displayed within a row.
MenuGets or sets the control’s popup menu that will be shown.
PointGets or sets coordinates of the invoked context menu (top-left corner) relative to the parent control. Inherited from BasePopupMenuShowingEventArgs.
RecordIndexGets the index of a record where the popup menu will be displayed.
RecordObjectGets a data object that corresponds to a row where the popup menu will be displayed.
RowGets the row where the popup menu will be displayed.
ScreenPointGets coordinates of the invoked context menu (top-left corner) relative to the screen. Inherited from BasePopupMenuShowingEventArgs.

The event data class exposes the following methods:

MethodDescription
ShowCustomMenu(IDXDropDownControlEx)Invokes a custom context menu instead of the control’s menu. Inherited from BasePopupMenuShowingEventArgs.
ShowCustomMenu(ContextMenuStrip)Invokes a custom context menu instead of the control’s menu. Inherited from BasePopupMenuShowingEventArgs.

Remarks

In the Office view (see PropertyGridControl.ActiveViewType), you can display brick buttons against properties by setting the PropertyGridControl.OptionsView.ShowRowBrick property to True (see PGridOptionsView.ShowRowBrick).

The RowBrickMenuShowing event allows you to populate the menu.

csharp
using DevExpress.Utils.Menu;

propertyGridControl1.RowBrickMenuShowing += propertyGridControl1_RowBrickMenuShowing;
private void propertyGridControl1_RowBrickMenuShowing(object sender, DevExpress.XtraVerticalGrid.Events.PopupMenuShowingEventArgs e) {
    if (e.Row.Properties.FieldName == "Appearance.BackColor")
        e.Menu.Items.Add(CreateDataBindingItem);
}
DXMenuItem createDataBindingItem;
protected DXMenuItem CreateDataBindingItem {
    get {
        if (createDataBindingItem == null) {
            DXMenuItem item = new DXMenuItem("Create Data Binding...");
            item.Click += (s, ee) => MessageBox.Show("'Create Data Binding...' is clicked.");
            createDataBindingItem = item;
        }
        return createDataBindingItem;
    }
}
vb
Imports DevExpress.Utils.Menu

Private Sub propertyGridControl1_RowBrickMenuShowing(ByVal sender As Object, ByVal e As DevExpress.XtraVerticalGrid.Events.PopupMenuShowingEventArgs) _
    Handles propertyGridControl1.RowBrickMenuShowing
    If e.Row.Properties.FieldName = "Appearance.BackColor" Then
        e.Menu.Items.Add(CreateDataBindingItem)
    End If
End Sub
Private createDataBindingItem1 As DXMenuItem
Protected ReadOnly Property CreateDataBindingItem() As DXMenuItem
    Get
        If createDataBindingItem1 Is Nothing Then
            Dim item As New DXMenuItem("Create Data Binding...")
            AddHandler item.Click, Sub(s, ee) MessageBox.Show("'Create Data Binding...' is clicked.")
            createDataBindingItem1 = item
        End If
        Return createDataBindingItem1
    End Get
End Property

Note

Items added using this event are not shown when the menu is invoked with a right-click on a property (see PGridOptionsView.ShowRowBrick).

You can also customize the brick buttons by handling the PropertyGridControl.CustomDrawRowBrick event.

See Also

CustomDrawRowBrick

ShowRowBrick

ActiveViewType

PropertyGridControl Class

PropertyGridControl Members

DevExpress.XtraVerticalGrid Namespace