alex

alex

  • NA
  • 2
  • 0

Button to change form size

Aug 29 2007 7:15 PM

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)