Subscribe to the Form.MouseClick event or override the OnMouseClick method.
Example override:
public class MyForm : Form { protected override void OnMouseClick(MouseEventArgs e) { base.OnMouseClick(e); Button btn = new Button { Location = e.Location, // e.Location - координаты мыши Visible = true, Text = "Some text" }; Controls.Add(btn); } }
Either event. Subscribe to it anywhere in the form:
MouseClick += MyForm_MouseClick;
Handler itself:
private void MyForm_MouseClick(object sender, MouseEventArgs e) { Button btn = new Button { Location = e.Location, // e.Location - координаты мыши Visible = true, Text = "Some text" }; Controls.Add(btn); }