yinwenle

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

其实两类控件在实现中是一样的,或者说是完全相同的,下面我只以listview控件来举例。

这个右击事件是写在listview事件中的例如:mouseover mousedown mouseup等等都可以气形式都是如下面的例子中的: 

private void listView1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {

      contextMenuStrip1.Show(MousePosition);//或者contextMenuStrip1.Show(listView1,new Point(e.X,e.Y));

                if (listView1.SelectedItems.Count ==0)
                {
                    下载ToolStripMenuItem.Enabled = false;

                }
                else
                {
                     下载ToolStripMenuItem.Enabled = true;

                }
            }
        }

posted on 2011-07-15 10:38  yinwenle  阅读(583)  评论(0编辑  收藏  举报