Resize form at runtime but after onload event

Essentially I wanted to resize my form based upon an ini setting which sets the global variable
m_blnCurrentFlyUpDownImageIndex.

I tried putting the following snippet in my forms onload sub but it didnt affect the form when it was actually loaded.

        If (m_blnCurrentFlyUpDownImageIndex = True) Then
            Me.btnFlyUpDown.BackgroundImage = ilsFlyoutButton.Images(0)
            Me.Size = New Size(Me.Size.Width, 600)
            m_blnCurrentFlyUpDownImageIndex = False
        Else
            Me.btnFlyUpDown.BackgroundImage = ilsFlyoutButton.Images(1)
            Me.Size = New Size(Me.Size.Width, 360)
            m_blnCurrentFlyUpDownImageIndex = True
        End If

I have a button that does the equivalent after the form is loaded which is
    Private Sub btnFlyUpDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFlyUpDown.Click
        If (m_blnCurrentFlyUpDownImageIndex = True) Then
            Me.btnFlyUpDown.BackgroundImage = ilsFlyoutButton.Images(0)
            Me.Size = New Size(Me.Size.Width, 600)
            m_blnCurrentFlyUpDownImageIndex = False
        Else
            Me.btnFlyUpDown.BackgroundImage = ilsFlyoutButton.Images(1)
            Me.Size = New Size(Me.Size.Width, 360)
            m_blnCurrentFlyUpDownImageIndex = True
        End If
    End Sub

How can I call this at runtime AFTER the form is loaded?
valtechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

iboutchkineCommented:
I think it is the same. After form is loaded, read the ini file and then
 Me.Size = New Size(Me.Size.Width, 600)

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
valtechAuthor Commented:
I am a newbie at VB.net, and this doesnt make sense to me. Where/How is this resize triggered programatically, after the form is displayed? Should it go in the form declaration in the "windows form designer" region?

        'fmCalibrationVerification
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(392, 573)
        Me.Controls.Add(Me.sbrCalibrationVerification)
        Me.Controls.Add(Me.grbTipSelector)
        Me.Controls.Add(Me.grpTipAngSelectionOverride)
        Me.Controls.Add(Me.grpMain)
        Me.Controls.Add(Me.lblJobDesc)
        Me.Controls.Add(Me.lblJobDescription)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "fmCalibrationVerification"
        Me.Text = "Calibration/Verification Version 0.1"
        Me.TopMost = True
        Me.grpMain.ResumeLayout(False)
        Me.grpRunMethod.ResumeLayout(False)
        Me.grpTipAngSelectionOverride.ResumeLayout(False)
        Me.grbTipSelector.ResumeLayout(False)
        CType(Me.sbpStatusInfo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.sbpTime, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.sbpDate, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.StatusTimer, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        .
        .

OK I tried it... Changed the above to be
        '
        'fmCalibrationVerification
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)


        'Me.ClientSize = New System.Drawing.Size(392, 573)
        If (m_blnCurrentFlyUpDownImageIndex = True) Then
            Me.btnFlyUpDown.BackgroundImage = ilsFlyoutButton.Images(0)
            Me.ClientSize = New System.Drawing.Size(392, 600)
            m_blnCurrentFlyUpDownImageIndex = False
        Else
            Me.btnFlyUpDown.BackgroundImage = ilsFlyoutButton.Images(1)
            Me.ClientSize = New System.Drawing.Size(392, 360)
            m_blnCurrentFlyUpDownImageIndex = True
        End If


        Me.Controls.Add(Me.sbrCalibrationVerification)
        Me.Controls.Add(Me.grbTipSelector)
        Me.Controls.Add(Me.grpTipAngSelectionOverride)
        Me.Controls.Add(Me.grpMain)
        Me.Controls.Add(Me.lblJobDesc)
        Me.Controls.Add(Me.lblJobDescription)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "fmCalibrationVerification"
        Me.Text = "Calibration/Verification Version 0.1"
        Me.TopMost = True
        Me.grpMain.ResumeLayout(False)
        Me.grpRunMethod.ResumeLayout(False)
        Me.grpTipAngSelectionOverride.ResumeLayout(False)
        Me.grbTipSelector.ResumeLayout(False)
        CType(Me.sbpStatusInfo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.sbpTime, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.sbpDate, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.StatusTimer, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

This worked, but is this the preferred method of doing things.. I thought messing around with the windows region is not a great thing to do...

Thanks,
Scott

0
valtechAuthor Commented:
Sorry.. my response may have been unclear..  I commented out the Me.clientsize original declaration and replaced with the code to control the size as you can see.
0
valtechAuthor Commented:
This didnt work.. as soon as I saved the project etc it reverted back to what VS.Net wanted. I added again in the onload and it seems to be working.. weird.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.