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

how to activated a closed form?

when i press a button, a form.Show is triggered
the form provides some reference information for me to input information in
the parent form, so i don't want to use ShowDialog.
besides, i want the form to opened once only

how can i do this?

i use
form1 frmReference;
if (frmReference == null)
{
frmReference = new form1();
}
frmReference.Show();

I can successfully control a form to be opened once only
but when i close the form, and press the button again...
there is error encountered....

thanks!
Nov 17 '05 #1
2 2580
My guess, without checking (late, lazy, sorry), and assuming frmReference is
global, is that
the form is disposed whilst closing so you have a reference in your parent
wich is not null but
the child form is gone (handles freed, memory in garbage, etc ...).

Why not pass a parent reference to the child form and when the child closes
down it notifies its parent of
it's closure, where the parent resets the child reference to null (so it can
be reconstructed with your button
click) ?

AinO.

PS. Specifying the error message does wonders (i was not very specific
myself, i know so 1-1).

"ywchan" <yw****@gmail.com> wrote in message
news:ey**************@TK2MSFTNGP12.phx.gbl...
when i press a button, a form.Show is triggered
the form provides some reference information for me to input information in the parent form, so i don't want to use ShowDialog.
besides, i want the form to opened once only

how can i do this?

i use
form1 frmReference;
if (frmReference == null)
{
frmReference = new form1();
}
frmReference.Show();

I can successfully control a form to be opened once only
but when i close the form, and press the button again...
there is error encountered....

thanks!

Nov 17 '05 #2
ywchan wrote:
when i press a button, a form.Show is triggered
the form provides some reference information for me to input information in
the parent form, so i don't want to use ShowDialog.
besides, i want the form to opened once only

how can i do this?

i use
form1 frmReference;
if (frmReference == null)
{
frmReference = new form1();
}
frmReference.Show();

I can successfully control a form to be opened once only
but when i close the form, and press the button again...
there is error encountered....

thanks!

Handle the disposed event of your form and set your reference to null in
this event.

Cheers
JB
if(PropertiesForm == null)
{
PropertiesForm = new frmProperties();
PropertiesForm.Disposed += new EventHandler(PropertiesForm_Disposed);
}
if(!PropertiesForm.Visible)
{
PropertiesForm.Show();
}
Nov 17 '05 #3

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

Similar topics

0
by: gencode | last post by:
I need to know if my form(main app) is activated or not at any given time. There are the Activated and Deactivated events and I can toggle a local flag but that does not help if the form starts...
1
by: slaprade | last post by:
I have a MDI form with the following Public fm2 As New Form2() Public fm3 As New Form3() and Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
7
by: Xero | last post by:
How do you detect whether a form has been closed or not? Thanks. -- Xero http://www.chezjeff.net My personal web portal
0
by: A_PK | last post by:
Hi I got the following environment.......Form1 and inside Form1, got Panel1.... I also got another new Form ...named Form2... Form1, Panel1 Form2 Inside Form1, I click a button to show Form2...
3
by: Dennis | last post by:
I thought that the Load Event fired first and the Activated event fired next when a control is shown. For example Dim myForm as New Form1 myForm.Show I put a breakpoint in the load event...
0
by: **Developer** | last post by:
Form.MdiChildActivate Event Occurs when a multiple document interface (MDI) child form is activated or closed within an MDI application. I need to know in the MdiChildActivate event handler...
0
by: pavan377 | last post by:
Hi folks, I got a requirement in my project where in when my application is activated another window should get activated and upon it my application should be present. Both should be in restored...
4
by: G .Net | last post by:
Hi Is there a way to explicitly get the Activated event of a form to be called? Thanks G
7
by: Kaster | last post by:
I am using the script below on several webpages, to pop up a window where people can order some things. It works well when shifting forth and back between the same page from where it is activated. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.