Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Opening a Single Instance of MDI Child form Using VB.NET

Opening a Single Instance of MDI Child form Using VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharphelptutorial
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 836050
    wrote on last edited by
    #1

    I am creating an MDI applicalion using VB.NET and I need to know how to restrict opening only one instance of each child form. Currently everytime I click on a child form it opens a new instance of it. If an instance of a particular child form is open and I click to open again it shouldn't let me. Your HELP is greatly appreciated.

    M 1 Reply Last reply
    0
    • U User 836050

      I am creating an MDI applicalion using VB.NET and I need to know how to restrict opening only one instance of each child form. Currently everytime I click on a child form it opens a new instance of it. If an instance of a particular child form is open and I click to open again it shouldn't let me. Your HELP is greatly appreciated.

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Hi. I'm not sure I understand what you mean. In your MDI application, are you clicking a menu item to instantiate a child form? If that's the case, then it should be simple in your parent form to maintain a private variable that can hold the child form. In the menu item code to open the child form, check if the private variable is nothing; if it is, set it to a new instance of your child form. If it isn't, then don't create a new child form instance, just use the Activate() method of the child form in the private variable to bring it to front. Something like this:

      ...
      Private _childForm as MyChildFormClass = nothing
      ...
      Private Sub OpenMyChildForm()
      If (_childForm Is Nothing) Then
      _childForm = new MyChildFormClass()
      _childForm.Show()
      Else
      _childForm.Activate()
      End If
      End Sub

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups