blah blah blah is here! blah blah » Close

up1down
link

Dear All,

Is it possible that with a click of a button, the form can resize (bigger and smaller) and some buttons/textboxes will appear?



Thank you in advance :)

last answered one year ago

4 answers

link

Making the "FormBorderStyle" property of the form as Fixed3D in the design of the form will fix the height/width of the form. AS our expert "Vulpes" told that u can increase/decrease the form using that code

// Enlarge the Form by 10%
private void button1_Click(object sender, EventArgs e)
{
this.Width = (int)(this.Width * 1.1);
this.Height = (int)(this.Height * 1.1);
}
// Reduce the Form by 10%
private void button2_Click(object sender, EventArgs e)
{
this.Width = (int)(this.Width * 0.9);
this.Height = (int)(this.Height * 0.9);
}


Now if the form is re sized..... then as a programmer u should also provide a button/link to bring the form to to its original size also.
// reset to original size
private void button3_Click(object sender, EventArgs e)
{
this.Width = 200; // just some number I had put here.
this.Height = 175; // just some number I had put here.
}


But as u will work on this, u will find that the after resizing the form u will have to re size the contents of the form too. Example: all text/buttons/textBox/comboBox/lists will also require to be re-positioned on the Form.

Top Left corner of ur form will remain fixed and the Form will enlarge/shrink from the bottom right corner of the form. So just be ready to re size "Everything" (also) in the form after re sizing the Form. Otherwise the "mismanaged" look of the re sized form will take away all the credit u should get for ur hard work.

My personal experience says that "The Look", "Easy to use", "Clean interface" of any windows application carries more Marks then what we expect from our users.

:)

up1down
link

Yep sure is ;)

Get into the code snippet for your button and just type in

Height = xx;
Width = yy;

xx and yy are numbers you can pick to set the size of your form.

This is a C# question right? If not, sorry to have wasted time...

I am sorry but I mean is the height and width of the FORM, not the button. As I saw, the form has size in the toolbox and we can change it, but.................... how we change this size parameters in using a button click? you are not wasting time, you are helping a noob :)

up2down
link

If you use Height and Width without qualification within a Form class, then the compiler will assume you mean the Height and Width properties of the form itself. You can make it absolutely explicit by preceding them with the 'this' keyword.

The following code will increase the form's height and width by 10% whilst keeping the top left hand corner of the form in the same position on the desktop:

private void button1_Click(object sender, EventArgs e)
{
this.Width = (int)(this.Width * 1.1);
this.Height = (int)(this.Height * 1.1);
}

up1down
link

It's easy, here's how to do both of the things you described:

void Englarge(){
this.Width = 640
this.Height = 480
hiddenButton1.Visible = true;
hiddenTextBox1.Visible = true;
}
void Shrink(){
this.Width = 320
this.Height = 240
hiddenButton1.Visible = false;
hiddenTextBox1.Visible = false;
}


Hope this helped!

Feedback