-2
if (pattern[x] == 0)
                {
                    Form1.button0.BackColor = Color.Yellow;

                }
                else if (pattern[x] == 1)
                {

                }
                else if (pattern[x] == 2)
                {

                }
                else
                {

                }

I'm trying to set the button backcolor, but whenever I try it doesn't recognise that button0 is a thing :/

2 Answers2

0

You need to create an instance of Form1 so something like this:

var myForm = new Form1();
if (pattern[x] == 0)
{
    myForm.button0.BackColor = Color.Yellow;
}
else if (pattern[x] == 1)
{
    //...
}
else if (pattern[x] == 2)
{
    //...
}
else
{
    //...
}
myForm.ShowDialog();

NOTE: ShowDialog() at the end will actually show your form as a dialog. You could just use .Show() but it depends on how you want to display the form. This should get your started though!

Belogix
  • 8,129
  • 1
  • 27
  • 32
0

If indeed button0 exists in your Form1 (it is created in your Form1.desginer.cs) you can simply access it by:

button0.BackColor = Color.Yellow;
apomene
  • 14,282
  • 9
  • 46
  • 72