Connecting Tech Pros Worldwide Help | Site Map

Trying to Resize an Active Form

Newbie
 
Join Date: Mar 2009
Posts: 26
#1: Mar 18 '09
I am trying to resize form1 aka (CipherForm) while the program is running.

I have Visual Studios 2003.

I have tried
Expand|Select|Wrap|Line Numbers
  1. private void CipherForm_Load(object sender, System.EventArgs e)
  2.         {
  3.             CipherForm h = new CipherForm(); 
  4.             h.Size = new Size(500, 500);
  5.         }
  6.  
What I want in the end is during an event the window will resize and exiting an event it will resize back.
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,743
#2: Mar 18 '09

re: Trying to Resize an Active Form


Try...

h.Height = 500;
h.Width = 500;


As for "during an event"... An event is a rather instantaneous thing. You get an event at mouse down... you don't get continuous events while the mouse button is down. You get an event for ... the com port pin going low... you don't get continuous events for it.
Newbie
 
Join Date: Mar 2009
Posts: 26
#3: Mar 18 '09

re: Trying to Resize an Active Form


Tried to do this to. It does not seem to resize.
Expand|Select|Wrap|Line Numbers
  1. private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
  2.         {
  3.             CipherForm h = new CipherForm(); 
  4.             h.Size = new Size(500, 500);
  5.             h.Height = 500;
  6.             h.Width = 500;
  7.  
  8.             KeyInstruction1.Visible = true;
  9.             KeyIn.Visible = true;
  10.             MaskEnbl.Visible = true;
  11.             MaskEnbl.Enabled = true;
  12.             KeyIn.Enabled = true;
  13.         }
  14.  
trying to resize of an ok from an openfile dialog
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,743
#4: Mar 18 '09

re: Trying to Resize an Active Form


Please use [code] tags.

As near as I can see there is nothing yet shown to even tell if it is resizing.
Line 3 you make a new form
You then make changes to the new form.
At no point do you .Show() the new form.
Newbie
 
Join Date: Mar 2009
Posts: 26
#5: Mar 18 '09

re: Trying to Resize an Active Form


Ohhhhhh....

Yeah that pops up a new form. Ok! But I wanted to resize the old form, not create a new form. Unless I can make the old form disapear while the new form is active. Do you know how to do this.

As you can tell I am quite new to this
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,148
#6: Mar 18 '09

re: Trying to Resize an Active Form


use the this keyword to refer to the current form(assuming the code you are writing is running on the form you want to resize)
Newbie
 
Join Date: Mar 2009
Posts: 26
#7: Mar 18 '09

re: Trying to Resize an Active Form


Yes!!!!!!!!!!!!!! Thanks that worked :) .
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,743
#8: Mar 18 '09

re: Trying to Resize an Active Form


... Otherwise use the reference to the first instance of your CypherForm.

At some point you had to make it. You assigned it to something.
Reply

Tags
resize window size


Similar C# / C Sharp bytes