由于没有IDE环境,所以程序就尽量简单了
不说了,你看程序吧
using System;
using System.Windows.Forms;
using System.Drawing;
class useonpaint:Form
{
public useonpaint()
{;}
static void Main()
{
Application.Run(new useonpaint());
}
protected override void OnMouseUp(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left) test(e);
}
private void test(MouseEventArgs e)
{
ContextMenu m = new ContextMenu();
this.ContextMenu= m;
// Create MenuItem objects.
MenuItem menuItem1 = new MenuItem();
MenuItem menuItem2 = new MenuItem();
// Set the Text property.
menuItem1.Text = "New";
menuItem2.Text = "Open";