Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 19th, 2007, 12:15 AM
Authorized User
 
Join Date: Oct 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to salman
Default Close all MdiChield form from open one form/Button

I've to Close all open MdiChield form from one form/button in VB.NET 2003 (FrameWork 1.0/2.0)
I'm using following ode. It neither gives error nor close any form

I've used Me.OwnedForms and Me.MdiChildren both but loop doesn't run more than one.

What's the reason or please tell be another code for this. Code must be run in FrameWork 1.0/2.0
Thanks.

        Dim f As Form
        ' For Each f In Me.OwnedForms
        For Each f In Me.MdiChildren
            f.Close()
        Next


 
Old November 20th, 2007, 08:50 PM
Authorized User
 
Join Date: Nov 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to bharatsaboo Send a message via Yahoo to bharatsaboo
Default

hi salman

try the following code

        For xx = 1 To Me.MdiChildren.Length
            Me.MdiChildren(xx - 1).Close()
        Next

Regards

Bharat
 
Old November 21st, 2007, 07:28 AM
Authorized User
 
Join Date: Oct 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to salman
Default

Dear Bharat
Thanks for your reply but

Me.MdiChildren.Length is giving 0 and loop never start
So nothing form colse for this

 
Old November 22nd, 2007, 01:52 AM
Authorized User
 
Join Date: Nov 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to bharatsaboo Send a message via Yahoo to bharatsaboo
Default

hi salman

are you setting the mdiparent property of the form to the parent form

i think you are forgetting that hence me.mdichildren.length is returning 0
 
Old November 23rd, 2007, 05:22 AM
Authorized User
 
Join Date: Oct 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to salman
Default

hi Bharat!

I have did IsMdiContainer=true for main forms and all other forms have IsMdiContainer=false as default
but me.mdichildren.length is returning 0


 
Old November 23rd, 2007, 08:14 AM
Authorized User
 
Join Date: Nov 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to bharatsaboo Send a message via Yahoo to bharatsaboo
Default

hi salman

you got me wrong

for the child form you have to set the parent form as below

childForm.mdiParent = mdiForm

Regards

Bharat
 
Old December 10th, 2007, 03:21 AM
Authorized User
 
Join Date: Oct 2003
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to salman
Default

Hi Bharat!
Thanks for your interest to solve my problem but
I only did IsMdiContainer=true for main form (MdiMain) and all other forms have IsMdiContainer=false as they default.
I've made a little example of my broblem ( One MDI and some blank forms) in VB.NET and mailed to you on your id

bharatsaboo@hotmail.com

Pease see it and reply me after correct. or tell me my mistake
Thanks in advance
My Email is ahmadsalmanpk@yahoo.com







Similar Threads
Thread Thread Starter Forum Replies Last Post
Close all MdiChield form from open one form salman .NET Framework 1.x 0 November 8th, 2007 12:32 AM
how to open a new VB 2005 form from a button? asimzeeshan Visual Basic 2005 Basics 4 August 20th, 2006 11:25 AM
disable close button in mdi form nkramanmca VB How-To 4 January 6th, 2005 12:31 AM
how to disable a close button on VB form chanti VB How-To 2 September 30th, 2004 06:21 AM
Get rid of the close button on a form Piblon Excel VBA 6 June 30th, 2004 02:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.