Как мне вызвать метод Form1_MouseClick в panel1, чтобы она появлялась только внутри panel?

namespace laba3
{
    public partial class Form2 : Form
    {
        int i = 1;

        public Form2()
        {
            InitializeComponent();
        }
        public void Form1_MouseClick(object sender, MouseEventArgs e)
        {

            if (e.Button == MouseButtons.Left)
            {
                Button b = new Button();
                this.Controls.Add(b);
                b.Location = new Point(e.X, e.Y);

                b.Text = "Панель " + i++;
                b.Click += new EventHandler(btn_Click);
            }
            void btn_Click(object se,EventArgs a)
            {
                MessageBox.Show((sender as Button).Text);
            }
        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}

Ответы (0 шт):