473,383 Members | 1,980 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,383 software developers and data experts.

Is this form already open?

Hi

I am opening a dialog using;

frmdialog = New frmdialognew
frmdialog.ShowDialog()

Is there a way to see if this dialog is already open to avoid opening
multiple instances of it?

Thanks

Regards
Nov 21 '05 #1
2 1817

August 8, 2004

Logically, since you are using the ShowDialog method, you can't
get back to the button or object to reopen the dialog again without
first closing the open one. If you have it in a button click event, you
would be creating a new instance of the dialog everytime you click
the button. Now if you were using the Show method, you could
check to see if it is open, if your design is a certain way.
You could evaluate the Form.Visible property and see if it is visible.
I do not know whether you want to see if it has been disposed of,
or just hidden from view. If it has been disposed of, you would not
know. This is where the design comes in. If you do not have any
code that disposes of the form then you can call the Show method
without showing multiple forms. If, however, the user closes the
window using the X button at the top right corner of the screen,
then you would not know. You could trap the form's closing event
and call E.Cancel = true and Me.Hide, so you can safely call the
form again with the same instance and solve this problem. Then
the user does not have to remember to click a button on the form
when closing the window. I hope that this leads you to your solution!
Joseph MCP
"John" wrote:
Hi

I am opening a dialog using;

frmdialog = New frmdialognew
frmdialog.ShowDialog()

Is there a way to see if this dialog is already open to avoid opening
multiple instances of it?

Thanks

Regards

Nov 21 '05 #2
Hi,
You can add a DefInstance property to the form to make the form have
only one instance. Add this to form1

Public Shared frm As Form1

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

frm = Me

End Sub

Public Shared ReadOnly Property DefInstance() As Form1

Get

If frm Is Nothing Then frm = New Form1

Return frm

End Get

End Property

To use

form1.definstance.showdialog

Ken

-------------------------

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:e6**************@TK2MSFTNGP09.phx.gbl...
Hi

I am opening a dialog using;

frmdialog = New frmdialognew
frmdialog.ShowDialog()

Is there a way to see if this dialog is already open to avoid opening
multiple instances of it?

Thanks

Regards

Nov 21 '05 #3

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

Similar topics

4
by: Tonya | last post by:
Hi, Does anyone have any example of how i can manage forms in my application?? I want to be able to reference my form instances that are currently open from other forms. why cant i open...
3
by: P | last post by:
Hi, Access 2002. I use DoCmd.OpenForm attached to command buttons to open one form from another form. All forms are open in dialog mode. When a user tries to open a form already opened from a...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
3
by: Susan Bricker | last post by:
Greetings. I have three forms that are open at the same time. They are related and cascading. The first form (frmEventAdd) is the anchor. Each event can have many Trials. The second form is...
5
by: smhaig | last post by:
In a vb 6 app in the activate event I was able to do some testing and if something failed, I was able to exit the form and return to the caller form. I have tried everything and searched web but...
9
by: RichG | last post by:
In VB 5 I could have a form named frmTest and open it with frmTest.Show Now in VB.net I have to Dim frm as New frmTest frm.show The problem is I only want one instance of frmTest open, not a...
2
by: Robert | last post by:
I am trying to give the user dynamic search capabilities to select almost any record in the database from criteria they select. Everything seems to work except when I open the display form to...
9
by: KelsMckin | last post by:
Hello, I was wondering if there was a way to check there was already a form open before opening a new one, sorry that doesnt seem clear, here is an example: The following button opens a new form...
1
by: ollyculverhouse | last post by:
Hi, I have a custom menubar which lets users jump to useful forms in my database. For example if I first open a form called 'Add Individual' then another called 'Add Firm', if i try opening...
19
by: =?Utf-8?B?R3JlZw==?= | last post by:
How can I tell via code if a Form is already open. Each time my forms load I have some initialization code that runs, but if the form is already open and hidden I don't want that initialization...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.