How can i get the check variable in the NewQuestion button to change the form check variable.
im looking at using the check value in another button after this button has changed it.
public Form1()
{
InitializeComponent();
}
int check = 0;
private void btnNewQuestion_Click(object sender, EventArgs e)
{
int check = 1;
}
I'm not sure of your main goal, I'm thinking there may better ways to do what you are trying to do. That said, you can simply reference your form level variable as you need to, within the same form.
public Form1()
{
InitializeComponent();
}
int check = 0; // form level variable
private void btnNewQuestion_Click(object sender, EventArgs e)
{
// int check = 1; // don't do this; this will create another 'check' variable that is only scoped within the button event
check = 1; // to set the form level check value, just reference the form level variable like so
}
private void btnSomeOtherButton_Click(object sender, EventArgs e)
{
// then reference it in the other button where you need it
if(check == 1)
{
// do some stuff
}
}