日期:2014-05-17 浏览次数:21066 次
ContextMenuStrip cmsA = new ContextMenuStrip();不知道是不是这一句有问题?this.ContextMenuStrip =。。。,在ListView中引用的时候是判断是在A组就调用A菜单,依此类推,我应该怎么写?
cmsA.ImageList = this.toolIcon;
/* 添加A菜单*/
this.ContextMenuStrip = cmsA;
cmsA.Opening += new CancelEventHandler(cmsA_Opening);
ContextMenuStrip cmsB = new ContextMenuStrip();
cmsA.ImageList = this.toolIcon;
/* 添加B菜单*/
this.ContextMenuStrip = cmsB;
cmsB.Opening += new CancelEventHandler(cmsB_Opening);
ContextMenuStrip cmsC = new ContextMenuStrip();
cmsC.ImageList = this.toolIcon;
/* 添加C菜单*/
this.ContextMenuStrip = cmsC;
cmsC.Opening += new CancelEventHandler(cmsC_Opening);
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WinFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
listView1.View = View.Details;
listView1.FullRowSelect = true;
listView1.Columns.Add("Item", 500);
listView1.Items.Add("1");
listView1.Items.Add("2");
ContextMenuStrip cms =