I have five buttons on one form that when clicked enables a bool each to be true or false, they also load a new form. When that form is loaded I need the new form to check first which of those bools are true or false. This will then lead to the form loading the correct data.
I set the bools to public thinking that this would work, and in the form2_load i checked which one is true. however this does not seem to work. I tried first by just changing a label and it’s text. The text doesn’t changed and I don’t think the bools are being read or checked.
Does anyone know what the problem could be?
Form1 code:
public bool Room1;
public bool Room2;
public bool Room3;
public bool Room4;
public bool Room5;
private void btnRoom1_Click(object sender, EventArgs e)
{
this.Hide();
//This displays Form2
Form2 RoomTemplate = new Form2();
RoomTemplate.Show();
Room1 = true;
Room2 = false;
Room3 = false;
Room4 = false;
Room5 = false;
}
Form2 code:
public Form3()
{
InitializeComponent();
Form2 Rooms = new Form2();
if (Rooms.Room1 == true)
{
lblTitle.Text = "Living Room";
}
if (Rooms.Room2 == true)
{
lblTitle.Text = "Dining Room";
}
This is one way to do it: