Back to Devexpress

RepositoryItemTokenEdit.BeforeShowMenu Event

windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitemtokenedit-775d3f58.md

latest2.8 KB
Original Source

RepositoryItemTokenEdit.BeforeShowMenu Event

Fires before this TokenEdit control’s popup menu is shown. Allows you to customize items within this menu.

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Events")]
public event BeforeShowMenuEventHandler BeforeShowMenu
vb
<DXCategory("Events")>
Public Event BeforeShowMenu As BeforeShowMenuEventHandler

Event Data

The BeforeShowMenu event's data class is DevExpress.XtraEditors.Controls.BeforeShowMenuEventArgs.

Remarks

The BeforeShowMenu property allows you to customize the popup menu, shown when end-users right-click this Token Edit Control. Event arguments provide the following properties:

  • e.Items - menu item collection. You can add new DXMenuItem objects to this collection to create custom menu items.
  • e.Location - sets the menu display position.
  • e.RestoreMenu - gets or sets whether or not the menu should be reset to its default state after it has been displayed. By default, custom items added to the e.Items collection are not automatically removed when the menu is hidden. Set this property to true in order to reset the menu before each display.

The code snippet below illustrates an example.

csharp
void Properties_BeforeShowMenu(object sender, DevExpress.XtraEditors.Controls.BeforeShowMenuEventArgs e) {
    e.Menu.Items.Insert(1, new DXMenuItem() { Caption = "Custom Menu Item" });
    e.Location = new Point(100, 100);
    e.RestoreMenu = true;
}
vb
Private Sub Properties_BeforeShowMenu(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.BeforeShowMenuEventArgs)
    e.Menu.Items.Insert(1, New DXMenuItem() { Caption = "Custom Menu Item" })
    e.Location = New Point(100, 100)
    e.RestoreMenu = True
End Sub

See Also

RepositoryItemTokenEdit Class

RepositoryItemTokenEdit Members

DevExpress.XtraEditors.Repository Namespace