using System;
using System.Windows.Forms;
using System.Drawing;
class myfrm : Form
{
ContextMenu cm;
MenuItem m1, m2, m3;
public myfrm()
{
cm = new ContextMenu();
m1 = new MenuItem("aaa");
m2 = new MenuItem("bbb");
m3 = new MenuItem("ccc");
cm.MenuItems.Add(m1);
cm.MenuItems.Add(m2);
cm.MenuItems.Add(m3);
this.ContextMenu = cm;
m1.Click +=new EventHandler(fun);
}
void fun(object o, EventArgs e)
{
MessageBox.Show("m1 clicked");
}
}
class Program
{
static void Main(string[] args)
{
myfrm f = new myfrm();
f.ShowDialog();
}
}
No comments:
Post a Comment