Friday, 2 December 2016

Upward Context Menu Strip on Button Click

private void button2_Click(object sender, EventArgs e)
        {
            Point screenpoint = button2.PointToScreen(new Point(button2.Left, button2.Bottom));
            if (screenpoint.Y + contextMenuStrip1.Size.Height < Screen.PrimaryScreen.WorkingArea.Height)
            {
                contextMenuStrip1.Show(button2, new Point(0, -contextMenuStrip1.Size.Height));
            }
            else
            {
                contextMenuStrip1.Show(button2, new Point(0, button2.Height));
            }
        }

No comments:

Post a Comment