Monday, December 2, 2019

Template using Panel to Load Form


VB.NET Template using Panel to Load Form

DOWNLOAD SOURCE CODE: TEMPLATE USING PANEL TO LOAD FORM


---------------------------------------------------------------------------------------------------------


'NOTE
'Panel3.AutoSize = True
'Panel1.AutoSize = False
'Panel2.AutoSize = False
'Panel4.AutoSize = True

'Panel4.Dock = DockStyle = Button
'Panel3.Dock = DockStyle.Top
'Panel1.Dock = DockStyle.Left
'Panel2.Dock = DockStyle.fill
'Panel4.Dock = DockStyle.left *nested under panel1

'Panel1.BorderStyle = BorderStyle.FixedSingle
'Panel2.BorderStyle = BorderStyle.FixedSingle

'Button1.FlatAppearance.BorderSize = 0
'Button2.FlatAppearance.BorderSize = 0
'Button3.FlatAppearance.BorderSize = 0
Public Class Form1


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label1.Text = 1
        Form2.TopLevel = False
        MainPanel.Controls.Clear()
        MainPanel.Controls.Add(Form2)
        Form2.Show()
        Form2.WindowState = System.Windows.Forms.FormWindowState.Maximized

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Label1.Text = 2
        Form3.TopLevel = False
        MainPanel.Controls.Clear()
        MainPanel.Controls.Add(Form3)
        Form3.Show()
        Form3.WindowState = System.Windows.Forms.FormWindowState.Maximized

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Label1.Text = 3
        Form4.TopLevel = False
        MainPanel.Controls.Clear()
        MainPanel.Controls.Add(Form4)
        Form4.Show()
        Form4.WindowState = System.Windows.Forms.FormWindowState.Maximized
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ToolStripStatusLabel1.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString()
        ToolStripStatusLabel2.Spring = True
        ToolStripStatusLabel2.Text = " "
        Timer1.Interval = 1000
        Timer1.Enabled = True
        Label1.Visible = False
        button_default()

    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        ToolStripStatusLabel3.Text = Date.Now
    End Sub



    Public Sub buttonselect(x As String)
        Select Case x
            Case Is = "1"
                Button1.PerformClick()
            Case Is = "2"
                Button2.PerformClick()
            Case Is = "3"
                Button3.PerformClick()

            Case Is = "0"

            Case Else

        End Select

    End Sub



    Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize
        buttonselect(Label1.Text)
    End Sub

    Public Sub button_default()
        Button1.ForeColor = Color.Black
        Button2.ForeColor = Color.Black
        Button3.ForeColor = Color.Black
        Button1.BackColor = Color.Transparent
        Button2.BackColor = Color.Transparent
        Button3.BackColor = Color.Transparent
    End Sub



    Private Sub Label1_TextChanged(sender As Object, e As EventArgs) Handles Label1.TextChanged
        button_default()
        Select Case Label1.Text
            Case Is = "1"
                Button1.BackColor = Color.FromArgb(204, 206, 219)
            Case Is = "2"
                Button2.BackColor = Color.FromArgb(204, 206, 219)
            Case Is = "3"
                Button3.BackColor = Color.FromArgb(204, 206, 219)

        End Select
    End Sub

    Private Sub MainPanel_Paint(sender As Object, e As PaintEventArgs) Handles MainPanel.Paint

    End Sub
End Class





---------------------------------------------------------------------------------------------------------




Public Class Form2
    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.AutoScroll = True
        Me.FormBorderStyle = FormBorderStyle.None
    End Sub
End Class




---------------------------------------------------------------------------------------------------------



Public Class Form3
    Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.AutoScroll = True
        Me.FormBorderStyle = FormBorderStyle.None
    End Sub
End Class



---------------------------------------------------------------------------------------------------------



Public Class Form4
    Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.AutoScroll = True
        Me.FormBorderStyle = FormBorderStyle.None
    End Sub
End Class


---------------------------------------------------------------------------------------------------------

No comments: