I have created some new method:
void newMethod(int x, int y)
{
Button B = new Button();
B.Size = new Size(100, 30);
B.Location = new Point(x, y);
B.Text = "Text";
Controls.Add(B);
}
Now I created a new panel inside some other method:
void Something()
{
Panel P = new Panel();
P.Size = new Size(300, 300);
P.Location = new Point(0, 0);
P.BackColor = new Color(Blue);
Controls.Add(P);
}
How do I add my first method in which I’ve created a button, to a panel in my second method?
Add the parent control as parameter:
Then: