Results 1 to 7 of 7

Thread: Checking for Instance of Form - RESOLVED

  1. #1

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401

    Checking for Instance of Form - RESOLVED

    hi,

    i have a MdiParent form that creates a new instance of another form and it display and naturally it is an MDIChild. Really simple stuff.

    the problem is that I have a timer on the MDIParent that does stuff (naturally ) and this causes problems with the MDIChild.

    What I would like to do, is inside the MDIParent's Timer control, place a check in there to see "if this particular MDIChild form is open, then don't execute this".

    is there a simple way to do this? (does this make sense?)

    thanks all
    Last edited by stingrae; May 26th, 2003 at 11:56 PM.
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    You could examine the MDIChildren array of the parent form and see if your child form is in it...

  3. #3

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    Slow_Learner,

    thanks - nice idea! i never thought of that.

    in my mind, i know exactly what you mean - i.e. create a For loop and check the name etc...

    but how do i code it? i can't find anything in help about MdiParent being an arry. is it a "For Each x in Y" or is it "For x - 0 to Parent.Count" style of loop?

    are you able to paste the basic for...loop structure?


    cheers
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  4. #4
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    Ought to be something like
    VB Code:
    1. Dim frmFoo As Form
    2. For Each frmFoo In frmParent.MDIChildren
    3.     If frmFoo.Name = "Something" Then
    4.         'Do some stuff
    5.     End If
    6. Next

    Post if it gives you problems, I haven't actually tried this but it should work.

  5. #5
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    or you could set a flag if the child form is open...just dump this in the parent

    VB Code:
    1. Dim blnFound As Boolean = False
    2. Dim frmChild As Form
    3.     For Each frmChild In Me.MdiChildren
    4. If TypeOf frmChild Is frmChoose Then
    5. frmChild.Focus()
    6. blnFound = True
    7.    Exit For                    
    8. End If
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  6. #6

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    they both worked.

    thanks guys!
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  7. #7
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    Using TypeOf like EyeTalion suggests is probably much better than using .Name. Glad it's fixed!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width