日期:2014-05-17  浏览次数:20871 次

鼠标右键弹出菜单位置的问题
我在窗口里通过代码动态添加了picturebox控件,想在控件上弹出鼠标右键菜单。当屏幕最大化的时候,鼠标右键菜单弹出的位置就是鼠标右击的位置,可是改变屏幕大小,弹出菜单的位置就改变了,不再是鼠标右击的位置了,这是怎么回事?求大神指导。以下是我鼠标单击事件的代码
private void eventpicturebox_MouseClick(object sender, MouseEventArgs e)
        {
            //弹出右键菜单
            if (e.Button == MouseButtons.Right)
            {
                PictureBox pe = (PictureBox)sender;
                this.contextMenuStrip1.Show(pe.Left + e.X, pe.Top + e.Y + this.toolStrip1.Height);
            }
        }

------解决方案--------------------
this.contextMenuStrip1.Show(MousePosition);
------解决方案--------------------
引用:
this.contextMenuStrip1.Show(MousePosition);


1楼正解
------解决方案--------------------
this.contextMenuStrip1.Show(MousePosition);

------解决方案--------------------
this.contextMenuStrip1.Show(MousePosition);