1
Reply

Button to change form size

Ask a question
alex

alex

17y
2.3k
1

Hello,

I was given the assignment to create a C# program in visual studio.net that has a form with a button on it, and when the button is clicked, the form will double in size.  Also, when the button is clicked again, the form will go back to its normal size.  I tried to do an if/else statement but that did not seem to work.  Here is what I have so far, any help would be great:

 

private void button2_Click(object sender, EventArgs e)

{

if (this.Width == 300)

this.Width +=300;

this.Height +=200;

else

this.Width -=300;

this.Height -=200;

}

 

 

I'm getting the error:  invalid expression term 'else' which I cannot determine why.


Answers (1)