C#,右击鼠标,窗体出现在鼠标右边

        private void DGV_DangQianPaiBan_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            Point screenPoint = Control.MousePosition;//鼠标相对于屏幕左上角的坐标
                if (e.Button == MouseButtons.Right)
                {
                    BanCiMingCheng myBanCiMingCheng = new BanCiMingCheng();
                    Point point = new Point(screenPoint.X, screenPoint.Y - 100);//窗体位置
                    myBanCiMingCheng.StartPosition = FormStartPosition.Manual;//窗体其实位置类型,manual由location指定
                    myBanCiMingCheng.Location = point;
                    myBanCiMingCheng.ShowDialog();
                }
        }

 

posted on 2014-01-05 09:52  AllEn—Carina  阅读(635)  评论(0编辑  收藏  举报