Hi, this is a simple question.
i want to click a button to show a form. If I use this code:
button_click()
{
MyNewForm myNewForm = new MyNewForm;
myNewForm.Show();
}
every time I click the button I get multiple instances of the form.
Understandably.
If I move the instantiation of the MyNewForm object out of the method so
that its a class scope field:
MyNewForm mynewform = new MyNewForm;
button_click()
{
myNewForm.Show();
}
This solves the multiple click problem, as it just keeps "showing" the form
object, but if I close the form and hence destroy the instance of the form, I
can no longer show the file and an error is raised as the form no longer
exists. Understandably.
This must be a common procedure. How does everyone do this??
Many thanks for your answers to this.
Ant 2 1318
Ant wrote: Hi, this is a simple question.
i want to click a button to show a form. If I use this code:
button_click() { MyNewForm myNewForm = new MyNewForm; myNewForm.Show(); }
every time I click the button I get multiple instances of the form. Understandably.
If I move the instantiation of the MyNewForm object out of the method so that its a class scope field:
MyNewForm mynewform = new MyNewForm;
button_click() { myNewForm.Show(); }
This solves the multiple click problem, as it just keeps "showing" the form object, but if I close the form and hence destroy the instance of the form, I can no longer show the file and an error is raised as the form no longer exists. Understandably.
This must be a common procedure. How does everyone do this??
The common procedure will be:
MyNewForm mynewform = new MyNewForm;
button_click()
{
if (myNewForm == null || myNewForm.Disposing || myNewForm.IsDisposed())
myNewForm = new MyNewForm();
myNewForm.Show();
}
Good luck,
MuZZy
Thank you very much MuZZY,
regards
Ant
"MuZZy" wrote: Ant wrote: Hi, this is a simple question.
i want to click a button to show a form. If I use this code:
button_click() { MyNewForm myNewForm = new MyNewForm; myNewForm.Show(); }
every time I click the button I get multiple instances of the form. Understandably.
If I move the instantiation of the MyNewForm object out of the method so that its a class scope field:
MyNewForm mynewform = new MyNewForm;
button_click() { myNewForm.Show(); }
This solves the multiple click problem, as it just keeps "showing" the form object, but if I close the form and hence destroy the instance of the form, I can no longer show the file and an error is raised as the form no longer exists. Understandably.
This must be a common procedure. How does everyone do this??
The common procedure will be:
MyNewForm mynewform = new MyNewForm;
button_click() { if (myNewForm == null || myNewForm.Disposing || myNewForm.IsDisposed()) myNewForm = new MyNewForm(); myNewForm.Show(); }
Good luck, MuZZy This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: c.anandkumar |
last post by:
Hi All -
I have some problems getting a small piece of javascript working
correctly for Firefox. Here is what I am trying to do -
1. I have a form (like a search form)
2. I have many groups...
|
by: Krzysztof Karnicki |
last post by:
I would like develop Form on my Windows Application, that is going to notify
the user, just like Microsoft Office 2003 shows that there are new mail
coming. When I use System.Windows.Forms.Form and...
|
by: missinglinq |
last post by:
I'd like to use acCmdAppMinimize with two forms on the screen at once. Currently, if I have a form opening the db (with DoCmd.Maximize in the OnLoad event) and then a popup form on top of the first...
|
by: painkiller |
last post by:
language: vb.net
environment: windows forms
.net : v1.1
i am having a checkedlistbox control that display document category such as text, image, video, audio etc. these values are coming from...
|
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,...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |