[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Resize form at runtime but after onload event

Posted on 2004-11-19
4
Medium Priority
?
205 Views
Last Modified: 2008-02-01
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?
0
Comment
Question by:valtech
  • 3
4 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 750 total points
ID: 12625773
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
 

Author Comment

by:valtech
ID: 12626048
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
 

Author Comment

by:valtech
ID: 12626060
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
 

Author Comment

by:valtech
ID: 12646105
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question