473,473 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

limiting to only one child form per type of form

Hello, every time I click on the button to open the child form, the form
opens fine, but if I click the button again, the same form opens again. I
would like to limit to one instance each particular form. I thought a would
add a condition to the code for the new form bottom click event (below), but
I don't know how to check to see if the form is already open. Could anyone
please help?

federico

Private Sub tbrMain_ButtonClick(ByVal sender As System.Object, ByVal e As _
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
tbrMain.ButtonClick
Dim NewMDIChild As New frmHardware
'Set the Parent Form of the Child window.
NewMDIChild.MdiParent = Me
'Display the new form.
NewMDIChild.Show()
End Sub
Nov 20 '05 #1
3 1548
"federico" <fc*****@rei.edu> schrieb
Hello, every time I click on the button to open the child form, the
form opens fine, but if I click the button again, the same form opens
again. I would like to limit to one instance each particular form.
I thought a would add a condition to the code for the new form bottom
click event (below), but I don't know how to check to see if the form
is already open. Could anyone please help?

federico

Private Sub tbrMain_ButtonClick(ByVal sender As System.Object, ByVal
e As _ System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
tbrMain.ButtonClick
Dim NewMDIChild As New frmHardware
'Set the Parent Form of the Child window.
NewMDIChild.MdiParent = Me
'Display the new form.
NewMDIChild.Show()
End Sub

Private m_Child As frmHardware

Private Sub OpenChild()
If m_Child Is Nothing Then
m_Child = New frmHardware
AddHandler m_Child.Closed, AddressOf OnChildClosed
m_Child.MdiParent = Me
m_Child.Show()
End If
m_Child.Activate()
End Sub

Private Sub OnChildClosed( _
ByVal sender As Object, ByVal e As System.EventArgs)

RemoveHandler m_Child.Closed, AddressOf OnChildClosed
m_Child = Nothing
End Sub
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
This works great! Thank you.

federico

"Armin Zingler" <az*******@freenet.de> wrote in message
news:u7*************@tk2msftngp13.phx.gbl...
"federico" <fc*****@rei.edu> schrieb
Hello, every time I click on the button to open the child form, the
form opens fine, but if I click the button again, the same form opens
again. I would like to limit to one instance each particular form.
I thought a would add a condition to the code for the new form bottom
click event (below), but I don't know how to check to see if the form
is already open. Could anyone please help?

federico

Private Sub tbrMain_ButtonClick(ByVal sender As System.Object, ByVal
e As _ System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
tbrMain.ButtonClick
Dim NewMDIChild As New frmHardware
'Set the Parent Form of the Child window.
NewMDIChild.MdiParent = Me
'Display the new form.
NewMDIChild.Show()
End Sub

Private m_Child As frmHardware

Private Sub OpenChild()
If m_Child Is Nothing Then
m_Child = New frmHardware
AddHandler m_Child.Closed, AddressOf OnChildClosed
m_Child.MdiParent = Me
m_Child.Show()
End If
m_Child.Activate()
End Sub

Private Sub OnChildClosed( _
ByVal sender As Object, ByVal e As System.EventArgs)

RemoveHandler m_Child.Closed, AddressOf OnChildClosed
m_Child = Nothing
End Sub
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
* "federico" <fc*****@rei.edu> scripsit:
Hello, every time I click on the button to open the child form, the form
opens fine, but if I click the button again, the same form opens again. I
would like to limit to one instance each particular form. I thought a would
add a condition to the code for the new form bottom click event (below), but
I don't know how to check to see if the form is already open.


<http://www.google.com/groups?selm=eXO279M%24CHA.1952%40TK2MSFTNGP12.phx. gbl>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

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

Similar topics

6
by: Kingdom | last post by:
I'm using this script to dynamicaly populate 2 dropdowns and dispaly the results. Choose a component type from the first drop down, lets say 'car' and the second box will list all the car...
10
by: Rogue Chameleon | last post by:
Hi all I have a input filed of type "textbox" into which I am expecting to get currency values (ie. 199.99). Is there a way that I can restrict the user to only entering 2 values after the...
18
by: OrenFlekser | last post by:
Hi I've posted this message couple of days ago, but I can't find it now, so sorry if you see it twice... Anyways - I have a text box, and I want my users to be able to write only in english...
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...
4
by: LCAdeveloper | last post by:
Help! Another newbie question I'm afraid. I have a toolbar on an MDI form, which I can control OK to produce a child form. When the child form is active, the appropriate MDI parent form toolbar...
2
by: wcrackshot78 | last post by:
I currently have three list boxes on my form, the information on each one is determined on what was selected on the one before it. The problem I'm having is the information that is used is pulled...
4
by: hashya | last post by:
Hi, I am trying to submit form in child window from parent window itself. However, not getting through it. e.g. Parent Window: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
3
by: zacks | last post by:
Forgive me if this has been already asked an answered, I did do a search both here and in VS2005 Help, but I can't find the answer to my question. I am developing an MDI application that is a...
2
by: Bob Johnson | last post by:
..NET 3.5: I have placed two controls at the top of an Mdi parent form. The top-most control is a Panel that is docked to the Top. Immediately below the Panel is a user control that is Anchored to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.