0
I’m looking to access members of Form1 using the Form2. For example, I want to change the color of "Panel1" that is inside "Form1" to black:
This is the way I’m doing it
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Form1 form1 = new Form1();
form1.panel1.BackColor = Color.Black;
}
}
However, it is impossible to do this, because the control "Panel1" does not appear within the class Form1
"instantiated".
If "Form1" is already open, it will not work because you are instantiating a new Form1 object
– Marceloawq
Really, was doing wrong, instantiating will create a new object.
– sYsTeM