D
D
Denis2021-03-03 16:31:33
C++ / C#
Denis, 2021-03-03 16:31:33

How to open an additional form?

How can I open an additional form at the cursor location so that it opens at the location where the cursor is.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2021-03-03
Folyush @AAGR

I understood everything, you need to overload the constructor and pass the necessary coordinates through it.
Code in the form to be called ( Form2 )

public Form2()
{
        InitializeComponent();
        StartPosition = FormStartPosition.Manual;
}
public Form2(Point newLocation) : this()
{
        Location = newLocation;
}

The code in the form with the help of which calls the first one when the mouse is clicked ( Form1 )
private void button1_Click(object sender, EventArgs e)
{
        new Form2(Cursor.Position).Show();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question