ok here is what I'm doing at the moment and its no good:
\\
Dim ThisForm as FormWhatever
Private Sub SomeKindOfClick (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles SomeKindOfClick .Click
If ThisForm Is Nothing Then
ThisForm = New FormWhatever
End If
ThisForm.Show()
End Sub
//
Now the 1st time I click, ThisForm comes up and thats great, if I
click again it sees that ThisForm is something and all is well, I only
get one instance of ThisForm. Now, if I close ThisForm it's dispose
method gets called but ThisForm does not turn into a nothing. It's
still a FormWhatever and when we get to the ThisForm.show part I get
and error that I cannot access a disposed object called FormWhatever.
What is the best way to make it so the user can only launch one
instance of a form, but when they close it, they are able to relaunch
one.
Pls & Thx,
Norst 8 1278
You might try:
If ThisForm Is Nothing orelse ThisForm.IsDisp osed then
"Poohface" wrote: ok here is what I'm doing at the moment and its no good:
\\ Dim ThisForm as FormWhatever
Private Sub SomeKindOfClick (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles SomeKindOfClick .Click If ThisForm Is Nothing Then ThisForm = New FormWhatever End If ThisForm.Show() End Sub //
Now the 1st time I click, ThisForm comes up and thats great, if I click again it sees that ThisForm is something and all is well, I only get one instance of ThisForm. Now, if I close ThisForm it's dispose method gets called but ThisForm does not turn into a nothing. It's still a FormWhatever and when we get to the ThisForm.show part I get and error that I cannot access a disposed object called FormWhatever.
What is the best way to make it so the user can only launch one instance of a form, but when they close it, they are able to relaunch one.
Pls & Thx, Norst
ok I got it working with this, but there must be a better way:
(same set up as below with this in click event)
\\
'if its 1st time launching
If Legend Is Nothing Then
Legend = New ColorLegend
Legend.Show()
Exit Sub
End If
'if its launched and open, bring it to the front
If Legend.Visible = True Then
Legend.TopMost = True
Legend.TopMost = False
Exit Sub
End If
'if its been launched and closed
Legend = New ColorLegend
Legend.Show()
//
Any ideas?
Thx,
Norst
On Sat, 23 Apr 2005 18:43:48 -0400, Poohface
<po******@shity erpantsoff.crap > wrote: ok here is what I'm doing at the moment and its no good:
\\ Dim ThisForm as FormWhatever
Private Sub SomeKindOfClick (ByVal sender As System.Object, ByVal e As System.EventAr gs) Handles SomeKindOfClick .Click If ThisForm Is Nothing Then ThisForm = New FormWhatever End If ThisForm.Show() End Sub //
Now the 1st time I click, ThisForm comes up and thats great, if I click again it sees that ThisForm is something and all is well, I only get one instance of ThisForm. Now, if I close ThisForm it's dispose method gets called but ThisForm does not turn into a nothing. It's still a FormWhatever and when we get to the ThisForm.show part I get and error that I cannot access a disposed object called FormWhatever.
What is the best way to make it so the user can only launch one instance of a form, but when they close it, they are able to relaunch one.
Pls & Thx, Norst
"Poohface" <po******@shity erpantsoff.crap > schrieb: Dim ThisForm as FormWhatever
Private Sub SomeKindOfClick (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles SomeKindOfClick .Click If ThisForm Is Nothing Then ThisForm = New FormWhatever End If ThisForm.Show() End Sub //
Now the 1st time I click, ThisForm comes up and thats great, if I click again it sees that ThisForm is something and all is well, I only get one instance of ThisForm. Now, if I close ThisForm it's dispose method gets called but ThisForm does not turn into a nothing.
See:
<URL:http://groups.google.d e/groups?selm=eIL SwL4CFHA.2072%4 0TK2MSFTNGP10.p hx.gbl>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
ok now that 2 of you.. None of my forms seem to have this IsDisposed
member? Seems to be no such thing? I see it in the documentation but
none of my Forms or Controls for that matter have it? What the deal
with that?
Norst
On Sun, 24 Apr 2005 01:49:25 +0200, "Herfried K. Wagner [MVP]"
<hi************ ***@gmx.at> wrote: "Poohface" <po******@shity erpantsoff.crap > schrieb: Dim ThisForm as FormWhatever
Private Sub SomeKindOfClick (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles SomeKindOfClick .Click If ThisForm Is Nothing Then ThisForm = New FormWhatever End If ThisForm.Show() End Sub //
Now the 1st time I click, ThisForm comes up and thats great, if I click again it sees that ThisForm is something and all is well, I only get one instance of ThisForm. Now, if I close ThisForm it's dispose method gets called but ThisForm does not turn into a nothing.
See:
<URL:http://groups.google.d e/groups?selm=eIL SwL4CFHA.2072%4 0TK2MSFTNGP10.p hx.gbl>
"Poohface" <po******@shity erpantsoff.crap > schrieb: ok now that 2 of you.. None of my forms seem to have this IsDisposed member? Seems to be no such thing? I see it in the documentation but none of my Forms or Controls for that matter have it? What the deal with that?
I assume that 'IsDisposed' is marked as an advanced member. You can show
advanced members in the code editor with the "Hide advanced members" option
under "Tools" -> "Options" -> "Text Editor" -> "Basic" -> "General".
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
OMG! I had no idea that was even there!! LOL I've been using VS for
over 3 years! hahaha
Thank you very much, now I'm wondering what else I've missed!
Norst
On Sun, 24 Apr 2005 02:27:13 +0200, "Herfried K. Wagner [MVP]"
<hi************ ***@gmx.at> wrote: "Poohface" <po******@shity erpantsoff.crap > schrieb: ok now that 2 of you.. None of my forms seem to have this IsDisposed member? Seems to be no such thing? I see it in the documentation but none of my Forms or Controls for that matter have it? What the deal with that?
I assume that 'IsDisposed' is marked as an advanced member. You can show advanced members in the code editor with the "Hide advanced members" option under "Tools" -> "Options" -> "Text Editor" -> "Basic" -> "General".
If it is not too much trouble, you can probably implement a Singleton Design
Pattern for your form. A Singleton Pattern guarentees only a single instance
of your class. Take a look at: http://msdn.microsoft.com/library/de...tondespatt.asp
It may be overkill on what your trying to do, but it is a slick way to
guarentee one instance of your form class.
"Poohface" wrote: ok here is what I'm doing at the moment and its no good:
\\ Dim ThisForm as FormWhatever
Private Sub SomeKindOfClick (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles SomeKindOfClick .Click If ThisForm Is Nothing Then ThisForm = New FormWhatever End If ThisForm.Show() End Sub //
Now the 1st time I click, ThisForm comes up and thats great, if I click again it sees that ThisForm is something and all is well, I only get one instance of ThisForm. Now, if I close ThisForm it's dispose method gets called but ThisForm does not turn into a nothing. It's still a FormWhatever and when we get to the ThisForm.show part I get and error that I cannot access a disposed object called FormWhatever.
What is the best way to make it so the user can only launch one instance of a form, but when they close it, they are able to relaunch one.
Pls & Thx, Norst
Yes, this is a much better way to do it. I think the idea of the class
and not the client controling the instances of the class is very slick
indeed. Thank you!
PS- Found a more VB tailored sample of this @ http://www.codeproject.com/Purgatory...n_patterns.asp
Thx again,
Norst
On Sun, 24 Apr 2005 13:41:02 -0700, "rmacias"
<rm*****@newsgr oup.nospam> wrote: If it is not too much trouble, you can probably implement a Singleton Design Pattern for your form. A Singleton Pattern guarentees only a single instance of your class. Take a look at:
http://msdn.microsoft.com/library/de...tondespatt.asp
It may be overkill on what your trying to do, but it is a slick way to guarentee one instance of your form class. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Job Lot |
last post by:
How can I prevent multiple instances of MdiChild form? I have a MdiParent
form with a DataGrid showing all the clients in the database. User clicks on
a row to open MdiChild form which display details of the client. User can
have multiple clients open at the same time, but how can I prevent them from
opening multiple instances of the client?
|
by: (Pete Cresswell) |
last post by:
I know I can open many instances of a given form, but I've never done it.
Now I'm analyzing an application where that seems like just the ticket: Many
investment funds, *lots* of data points for each fund, and a desire by the users
to see several funds presented side-by-side.
Is opening, say, five instances of the same form real-world-doable?
--
PeteCresswell
|
by: logicalfeline |
last post by:
How do you prevent multiple instances of a program from running?
Cat
|
by: Brian Keating EI9FXB |
last post by:
Hello there,
What is the best way in c# to prevent multiple instances of my application
running at same time on one machine?
thanks
Brian
|
by: Clark Stevens |
last post by:
I just finished a WinForms app in VB.NET. I want to allow the user to be
able to run multiple instances of the program like you can with Notepad and
Wordpad. The way it is now, once I run the executable I can not run another
instance as long as the first instance is running. How can I change this
behavior? Thanks.
| |
by: Rich |
last post by:
Hello,
my app opens a 2nd form (form2) by clicking a button on the first form
(form1). I do not want to open form2 in modal form, but I only want one
instance of form2 open. So if someone re-clicks the button on form1 there
will not be multiple instances of form2. I created a module level boolean
var in form1 and a property in form1 to control the loading of form2, but I
am having a problem resetting the value of this boolean var. ...
|
by: Job Lot |
last post by:
How can I prevent multiple instances of a C# windows forms application.
VB.NET provides My.Application.StartupNextInstance Event to do this. Is there
any C# equivalent as well?
Thanks
|
by: Tony K |
last post by:
I have a MDI application. On the menu toolstrip child forms are selected
from one of the menus. I don't want to play the disable/enable menu item
game. I have selected that open forms are added to the "Window" menu item.
What I'm looking for is when the user clicks on the menu item to open the
form, how can I check to see if it's open already and if so then set the
focus (if possible).
What happens now is if the menu item is clicked...
|
by: Neil |
last post by:
"lyle" <lyle.fairfield@gmail.comwrote in message
news:48c3dde7-07bd-48b8-91c3-e157b703f92b@f3g2000hsg.googlegroups.com...
Question for you. I'm doing something similar, only, instead of opening the
forms all at once, I'm opening them as needed. I have a main form with
multiple records; and then I have a pop-up form that the user opens with
button. The pop-up form contains one record relating to the current record
in the main form (but...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |