473,394 Members | 1,715 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.

Single instance form (child) on MDI

What is the best way to do this? I want to have a child form in an MDI
window that can only ever have one instance of open... if one is already
opened I want to use that form and not make another... any suggestions? I
have one idea but looking to see what alternatives are out there. thanks!
Mar 9 '07 #1
3 3584
Try

Me.Cursor = Cursors.WaitCursor

If IsNothing(frmCust) Then

frmCust = New frmCustomers

frmCust.MdiParent = Me

frmCust.Show()

Else

frmCust.BringToFront()

End If

Finally

Me.Cursor = Cursors.Default

End Try
--
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------
"Smokey Grindel" <no****@nospam.comschreef in bericht
news:uJ**************@TK2MSFTNGP02.phx.gbl...
What is the best way to do this? I want to have a child form in an MDI
window that can only ever have one instance of open... if one is already
opened I want to use that form and not make another... any suggestions? I
have one idea but looking to see what alternatives are out there. thanks!

Mar 9 '07 #2
On Mar 9, 8:35 am, "Smokey Grindel" <nos...@nospam.comwrote:
What is the best way to do this? I want to have a child form in an MDI
window that can only ever have one instance of open... if one is already
opened I want to use that form and not make another... any suggestions? I
have one idea but looking to see what alternatives are out there. thanks!
This is screaming singleton to me.

Here's the basic pattern:

Public Class MyForm

Private Sub New()
InitializeComponent()
' This prevents the class from being instantiated directly.
End Sub

Private Shared _Instance As MyForm
Public Shared ReadOnly Property Instance() As MyForm
Get
' Instantiate the class if needed, otherwise return the
current class
If (_Instance Is Nothing) Then _Instance = New MyForm()
Return _Instance
End Get
End Property

End Class

Then in the MDI parent you can do this to add the child form:

MyForm.Instance.MdiParent = Me
MyForm.Instance.Show()

For more (and better implementations) see Jon Skeet's article at
http://www.yoda.arachsys.com/csharp/singleton.html

Beware it's in C#

Thanks,

Seth Rowe

Mar 9 '07 #3
thats actually the say I already had it :) good to know someone else was
thinking similar

" Screaming Eagles 101" <se*********@online.pleasewrote in message
news:3O******************************@scarlet.biz. ..
Try

Me.Cursor = Cursors.WaitCursor

If IsNothing(frmCust) Then

frmCust = New frmCustomers

frmCust.MdiParent = Me

frmCust.Show()

Else

frmCust.BringToFront()

End If

Finally

Me.Cursor = Cursors.Default

End Try
--
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
-------------------------------------------------
"Smokey Grindel" <no****@nospam.comschreef in bericht
news:uJ**************@TK2MSFTNGP02.phx.gbl...
>What is the best way to do this? I want to have a child form in an MDI
window that can only ever have one instance of open... if one is already
opened I want to use that form and not make another... any suggestions? I
have one idea but looking to see what alternatives are out there. thanks!


Mar 9 '07 #4

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

Similar topics

0
by: Phil Powell | last post by:
class DepartmentTree { function &buildTree($id) { static $html; if (!isset($html)) { // DO STUFF HERE TO $html } // DO MORE STUFF if ($condition_is_met) $this->buildTree($newID);...
3
by: Giulio Mastrosanti | last post by:
Which is the instance name of the starting form of an application? I want to access his controls and variables from another form but can't find the way... Which is the property I can use and...
0
by: Sakharam Phapale | last post by:
Hi All, How to show each instance of child form in Taskbar. In my application I have following forms. frmMain :- MDI Parent frmChild :- MDI Child, Maximize state I want to show only active...
2
by: mike w. | last post by:
I want to have a single instance of a base class that all the child classes inherits from. The base class is going load data from text files and this only needs to be done once. What I don't need...
0
by: mabond | last post by:
Firstly I hope I'm in the right forum ..... if not can someone re-direct me please. I have an application with a main form properties set to mdiparent = true. Toolbar button allows user to open...
10
by: John M. Gabriele | last post by:
The following short program fails: ----------------------- code ------------------------ #!/usr/bin/python class Parent( object ): def __init__( self ): self.x = 9 print "Inside...
1
by: dnzone | last post by:
I have a MDI Form with a menu and when i click on the menu it will open the MDI child but if i click it multiple time it will create multiple instance fo the child. What i want is no matter how...
0
by: Miro | last post by:
I searched google and I think I have solved the issue. Again, if someone could quickly skim over my example and lemmi know if it is the "correct" way of doing things. It works, but again - is it...
7
by: =?Utf-8?B?TWF0dA==?= | last post by:
Hi I have an app that runs without a main form, just a notification icon, when the user clicks the icon the form is shown, and when the form is minimized it's hidden. This all works great,...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.