Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Using an Observer design pattern to keep multiple forms up to date

, 29 May 2005
This article demonstrates how multiple forms can be updated simultaneously using Singleton and Observer Design Patterns.
observerdesignpattern.zip
ObserverDesignPattern
ObserverDesignPattern
bin
ObserverDesignPattern.exe
ObserverDesignPattern.vbproj.user
Public Class frmMain
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        '
        'frmMain
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.IsMdiContainer = True
        Me.Name = "frmMain"
        Me.Text = "frmMain"

    End Sub

#End Region

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ifrmChild0 As New frmChild
        Dim ifrmChild1 As New frmChild
        Dim ifrmChild2 As New frmChild
        Dim ifrmChild3 As New frmChild

        ifrmChild0.MdiParent = Me
        ifrmChild1.MdiParent = Me
        ifrmChild2.MdiParent = Me
        ifrmChild3.MdiParent = Me

        ifrmChild0.Show()
        ifrmChild1.Show()
        ifrmChild2.Show()
        ifrmChild3.Show()

        Me.LayoutMdi(MdiLayout.TileVertical)

    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Nigel-Findlater
Software Developer (Senior)
Switzerland Switzerland
I am a Software Engineer currently working in a Re Insurance company.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150129.1 | Last Updated 30 May 2005
Article Copyright 2005 by Nigel-Findlater
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid