Trying to Resize an Active Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chris52672
    New Member
    • Mar 2009
    • 26

    Trying to Resize an Active Form

    I am trying to resize form1 aka (CipherForm) while the program is running.

    I have Visual Studios 2003.

    I have tried
    Code:
    private void CipherForm_Load(object sender, System.EventArgs e)
    		{
    			CipherForm h = new CipherForm(); 
    			h.Size = new Size(500, 500);
    		}
    What I want in the end is during an event the window will resize and exiting an event it will resize back.
    Last edited by tlhintoq; Mar 18 '09, 04:41 PM. Reason: Added [CODE]...[/CODE] tags
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    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.

    Comment

    • chris52672
      New Member
      • Mar 2009
      • 26

      #3
      Tried to do this to. It does not seem to resize.
      Code:
      private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
      		{
      			CipherForm h = new CipherForm(); 
      			h.Size = new Size(500, 500);
      			h.Height = 500;
      			h.Width = 500;
      
      			KeyInstruction1.Visible = true;
      			KeyIn.Visible = true;
      			MaskEnbl.Visible = true;
      			MaskEnbl.Enabled = true;
      			KeyIn.Enabled = true;
      		}
      trying to resize of an ok from an openfile dialog

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        Please use
        Code:
         ..your code here
        tags

        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.

        Comment

        • chris52672
          New Member
          • Mar 2009
          • 26

          #5
          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

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            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)

            Comment

            • chris52672
              New Member
              • Mar 2009
              • 26

              #7
              Yes!!!!!!!!!!!! !! Thanks that worked :) .

              Comment

              • tlhintoq
                Recognized Expert Specialist
                • Mar 2008
                • 3532

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

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

                Comment

                Working...