473,394 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

MDI Child Forms

I have an MDI app...

How should I open child forms in a way that I can ensure that only one
instance of any child form can be open at a time?

TIA
Nov 21 '05 #1
2 1419
"C CORDON" <tc******@hotmail.com> schrieb:
I have an MDI app...

How should I open child forms in a way that I can ensure that only one
instance of any child form can be open at a time?


\\\
Private m_Child As Form2

Private Sub Button1_Click( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles Button1.Click
If m_Child Is Nothing Then
m_Child = New Form2()
m_Child .MdiParent = Me
AddHandler m_Child.Load, AddressOf Me.MdiChild_Load
AddHandler m_Child.Closed, AddressOf Me.MdiChild_Closed
End If
m_Child.Show() ' ...
End Sub

Private Sub MdiChild_Load( _
ByVal sender As Object, _
ByVal e As EventArgs _
)
MsgBox( _
"MDI child with handle " & _
DirectCast(sender, Form).Handle.ToString() & _
" loaded!" _
)
End Sub

Private Sub MdiChild_Closed( _
ByVal sender As Object, _
ByVal e As EventArgs _
)
MsgBox( _
"MDI child with handle " & _
DirectCast(sender, Form).Handle.ToString() & _
" closed!" _
)
m_Child = Nothing
End Sub
///

Alternatively you can implement the Singleton design pattern in your MDI
child form:

Implementing the Singleton Pattern in C#
<URL:http://www.yoda.arachsys.com/csharp/singleton.html>

Exploring the Singleton Design Pattern
<URL:http://msdn.microsoft.com/library/en-us/dnbda/html/singletondespatt.asp>

Design Pattern: Singleton in C#
<URL:http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=486>

Design Patterns: Singleton
<URL:http://www.dofactory.com/Patterns/PatternSingleton.aspx>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
C

An alternative on the way from Herfried that I use now can you find in this
message

http://groups-beta.google.com/group/...d66101d43e80e3

Cor
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
3
by: Lance | last post by:
I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing MDI...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
2
by: Lenster | last post by:
Environment --------------- Visual Studio.NET 2003 Version 7.1.3088 ..NET Framework 1.1 Version 1.1.4322 SP1 XP Professional 5.1.2600 SP2 Build 2600 Problem Description...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.