Frank Uray said:
Hi all
How can I display a Menu in windows within a
C# application without any form.
It has to be shown on the current windows cursor position.
Thanks for any help.
Regards
Frank
Loosely based on the msdn doc for ContextMenus:
public partial class Form1 : Form
{
private ContextMenu cm = new ContextMenu();
public Form1()
{
InitializeComponent();
this.ContextMenu = cm;
cm.Popup +=new EventHandler(MyPopupEventHandler);
}
private void MyPopupEventHandler(System.Object sender,
System.EventArgs e)
{
// Define the MenuItem objects to display for the TextBox.
MenuItem menuItem1 = new MenuItem("&Copy");
MenuItem menuItem2 = new MenuItem("&Find and Replace");
// Define the MenuItem object to display for the PictureBox.
MenuItem menuItem3 = new MenuItem("C&hange Picture");
// Clear all previously added MenuItems.
cm.MenuItems.Clear();
cm.MenuItems.Add(menuItem1);
cm.MenuItems.Add(menuItem2);
cm.MenuItems.Add(menuItem3);
}