I have one form and a button inside it, how can i toggle the window height, so when i click on the button for the first time, the window height will increase by 166, and when i click on the button for the second time, the height will be decreased by 166.
Sorry for the question being stupid but i got really confused ;thanks
private void button2_Click(object sender, EventArgs e)
{
int FormHeight = this.Height;
int FormHeightBefore = FormHeight;
if (this.Height == FormHeightBefore)
{//toggle off
this.Height = this.Height + 166;
}
else {
//toggle on
this.Height = this.Height - 166;
}
}
I tried with the code above but the it doesn’t worked, Whenever i press the button, the form height still increasing
1 Answer