怎样实现c# winform中listbox控件的右键单击事件,而且单击同时还要使item被选中,如何办到? 
会的麻烦解决一下,谢了~

解决方案 »

  1.   

    处理MouseDow事件:
    不要设定ListBox的ContextMenu 
     private void listbox1_MouseDown(object sender, MouseEventArgs e)
            {
                if (e.Button == MouseButtons.Right)
                {                int index = listbox1.IndexFromPoint(e.Location);
                    if (index >= 0)
                    {
                        listbox1.SelectedIndex = index;
                        this.deleteMenu.Show(this.listbox1,e.Location);
                    }
                }
            }