'How to get inside form object global location?

I want to make a navigation bar in C# forms, when clicking on a button in the navigation bar a new form opens, and I want to set the form start position on a spesific object location in the main form. so the main question is : Can I get location of objects in form in relation to the user screen?

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    btn1 btn1;
    btn2 btn2;
    btn3 btn3;
    Point loc;
    private void Form1_Load(object sender, EventArgs e)
    {
        btn1 = new btn1();
        btn1.Show();
        loc = panel1.Location;
        btn1.Left = loc.X;
        btn1.Top = loc.Y;
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (btn1 == null)
        {
            btn1 = new btn1();
            btn1.Show();
        }
        if (btn2 != null)
        {
            btn2.Close();
            btn2 = null;
        }
        if (btn3 != null)
        {
            btn3.Close();
            btn3 = null;
        }
    }

    private void button2_Click(object sender, EventArgs e)
    {
        if (btn2 == null)
        {
            btn2 = new btn2();
            btn2.Show();
        }
        if (btn1 != null)
        {
            btn1.Close();
            btn1 = null;
        }
        if (btn3 != null)
        {
            btn3.Close();
            btn3 = null;
        }
    }

    private void button3_Click(object sender, EventArgs e)
    {
        if (btn3 == null)
        {
            btn3 = new btn3();
            btn3.Show();
        }
        if (btn2 != null)
        {
            btn2.Close();
            btn2 = null;
        }
        if (btn1 != null)
        {
            btn1.Close();
            btn1 = null;
        }
    }
}

}

I want to set the start position of the Orange form (B) to (A) location



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source