windowsforms-devexpress-dot-xtraeditors-dot-pictureedit.md
Fires when the context menu is about to be displayed.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXCategory("Events")]
public event PopupMenuShowingEventHandler PopupMenuShowing
<DXCategory("Events")>
Public Event PopupMenuShowing As PopupMenuShowingEventHandler
The PopupMenuShowing event's data class is DevExpress.XtraEditors.Events.PopupMenuShowingEventArgs.
The Picture Editor fires the PopupMenuShowing event when the context menu is about to be displayed and id the Properties.ShowMenu option is enabled. Handle the PopupMenuShowing event to customize the context menu or to prevent the menu from being displayed.
The following table lists event parameters:
| Property | Description |
|---|---|
e.Point | Allows you to obtain the position at which the editor is right-clicked. |
e.PopupMenu | Allows you to access and customize the menu. The menu is represented by a DXPopupMenu object. |
e.RestoreMenu | Allows you to specify whether to restore the context menu to the default settings after the menu has been displayed. |
e.Cancel | Allows you you to prevent the menu from being displayed. |
The following example adds the “Properties” menu item to the Picture Editor’s context menu if the editor displays an image:
public Form1() {
InitializeComponent();
pictureEdit1.PopupMenuShowing += PictureEdit1_PopupMenuShowing;
}
void PictureEdit1_PopupMenuShowing(object sender, DevExpress.XtraEditors.Events.PopupMenuShowingEventArgs e) {
e.RestoreMenu = true;
if(pictureEdit1.EditValue != null)
e.PopupMenu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Properties",
new EventHandler(OnProperties_Click),
svgImageCollection1["properties"],
DevExpress.Utils.Menu.DXMenuItemPriority.Normal));
}
void OnProperties_Click(object sender, EventArgs e) {
// Do something when a user clicks the "Properties" item.
}
Public Sub New()
InitializeComponent()
AddHandler pictureEdit1.PopupMenuShowing, AddressOf PictureEdit1_PopupMenuShowing
End Sub
Private Sub PictureEdit1_PopupMenuShowing(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Events.PopupMenuShowingEventArgs)
e.RestoreMenu = True
If pictureEdit1.EditValue IsNot Nothing Then
e.PopupMenu.Items.Add(New DevExpress.Utils.Menu.DXMenuItem("Properties", New EventHandler(AddressOf OnProperties_Click), svgImageCollection1("properties"), DevExpress.Utils.Menu.DXMenuItemPriority.Normal))
End If
End Sub
Private Sub OnProperties_Click(ByVal sender As Object, ByVal e As EventArgs)
' Do something when a user clicks the "Properties" item.
End Sub
The image below shows the result:
The PopupMenuShowing event is equivalent to the RepositoryItemPictureEdit.PopupMenuShowing event.
See Also