STYLISH STYLISH - 4 years ago 229
Vb.net Question

How to set a Windows Form size to maximum if the last Form's size is on maximum

I'm working on an app that contains two windows form:



I want that if user change the size of first form to maximum size that contains all desktop . the next form when loaded, it's size change to maximum .

I wrote this but not worked:

Private Sub sc(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
If Me.Size = New Size(MaximumSize) Then
MainMenu.Size = New Size(MaximumSize)
End If
End Sub


I'd be happy if you can help me.

Answer Source

I put this code in the form2_load part and worked

   Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    'Maximize form size if the past form size is maximized 
    If Form1.WindowState = FormWindowState.Maximized Then
        Me.WindowState = FormWindowState.Maximized
    End If
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download