-
Jul 29th, 2013, 04:08 AM
#1
Forms side by side, sharing monitor work area. 2nd form, panels created at runtime
I know it's simple... the 2nd form and panels are created at runtime. The new form gets it's X location from the main form's X coordinates + width.
Unless someone beats me to it, I'll update the code to add a snap function when moving the forms just as soon as I figure out how to do this with a dynamically created form.
Code below the image.
Code:
Option Strict On
Imports System.Resources
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Sets Form1's height, width and location.
'Width is your monitor's working area divided by 2
Me.Width = CInt(Screen.PrimaryScreen.WorkingArea.Width / 2)
Me.Height = Screen.PrimaryScreen.WorkingArea.Height
Me.Location = New Point(0, 0)
'Panel control created for Form1
Dim panel1 As New Panel
Me.Controls.Add(panel1)
panel1.Dock = DockStyle.Right
panel1.Width = 335
panel1.BackColor = Color.White
panel1.BackgroundImage = My.Resources.mr 'Change mr to your Resource image
'Another form created called Form2
Dim form2 As New Form
form2.Show(Me)
form2.Text = "Form2"
form2.BackColor = Color.White
'Sets Form2's height, width and location
'New Form2's location is Form1's X coordinates + width, Y
form2.Width = Me.Width
form2.Height = Me.Height
form2.Location = New Point((Me.Location.X + Me.Width), Me.Location.Y)
'Panel control created for Form2
Dim panel2 As New Panel
form2.Controls.Add(panel2)
panel2.Dock = DockStyle.Left
panel2.Width = 335
panel2.BackColor = Color.White
panel2.BackgroundImage = My.Resources.mrs 'Change mrs to your Resource image
End Sub
End Class
Last edited by Peter Porter; Jul 29th, 2013 at 04:32 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|