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

Why Form2 does not appear on the screen?

Hi all,

I have made a MDI application.Let's say FrmSession and FrmProperties.I
want to create something like Photoshop.There are allways many
instances of FrmSession but at each there is only one instance of
FrmProperties.But the problem:

Every time the user makes a new session i create a new instance of
FrmSession in my method - let's say NewSession - and then i call
FrmProperties.Show() .

private void NewSession()
{
FrmSession newsession = new FrmSession();
myfrmproperties.Show(); // has been created it elesewhere & there
is only one insance of it
}

but the problem shows itself here.If the user closees the
FrmProperties; then the next time myfrmproperties.Show does not show
the form on the screen.I have checked if it has been nulled but debuger
says there is one intance.what is wrong with my code?

Jul 8 '06 #1
5 1177
Liewe
2
Im not a guru, but I think hitting the cross does destroy the form.

I think you can solve it by adding an eventlistener to the formclosing event like:

this.Closing += new System.ComponentModel.CancelEventHandler(this.Form 2_Closing);

With a method like this:

private void Form2_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = !close;
}

With close a boolean set to true when you really close your application (else it wont) and false if you dont really want to close it you still have to hide it somehow then :)
Jul 8 '06 #2
I guess that this line
myfrmproperies.Show(); // has been created it elesewhere & there
doesn't throw a NullReferenceException but, instead throw an
ObjectDisposedException, doesn't it?

override FormClosing() for it!

"Behzad" <Se*********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi all,

I have made a MDI application.Let's say FrmSession and FrmProperties.I
want to create something like Photoshop.There are allways many
instances of FrmSession but at each there is only one instance of
FrmProperties.But the problem:

Every time the user makes a new session i create a new instance of
FrmSession in my method - let's say NewSession - and then i call
FrmProperties.Show() .

private void NewSession()
{
FrmSession newsession = new FrmSession();
myfrmproperties.Show(); // has been created it elesewhere & there
is only one insance of it
}

but the problem shows itself here.If the user closees the
FrmProperties; then the next time myfrmproperties.Show does not show
the form on the screen.I have checked if it has been nulled but debuger
says there is one intance.what is wrong with my code?

Jul 9 '06 #3
Hi,

yes,what do you guess?

Thanks

Jul 9 '06 #4
hu?

"Behzad" <Se*********@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hi,

yes,what do you guess?

Thanks

Jul 10 '06 #5
Behzad wrote:
Hi,

yes,what do you guess?

Thanks
I think what Lloyd was trying to tell you is that when a form that was
opened with .Show is closed, it is automatically disposed.

You need to override the FormClosing event and instead of closing the
form, you need to .Hide the form. Then you will be able to show the
form again later.

Chris

Jul 10 '06 #6

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

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
2
by: dawn | last post by:
Hi, I'm trying to capture part of Form2 into a bitmap when I click on a button on the main form (form1). After advice I'm using the following code : System.IntPtr...
5
by: nadir b | last post by:
hi I don't know how to change for exemple a form1 caption text from form2 don't forget that form2 has created from form1 I want sample code with c# *** Sent via Developersdex...
3
by: Will | last post by:
Hey friends, in vb 6.0, if you wanted to display a form on top of another and, in a way lock the screen on the form, you use form2.show 1 and placing the '1' after the show, will lock the...
5
by: PAPutzback | last post by:
Form2 has one purpose to open and list some names and ids. I want to handle the list box click event on form2 so I can get the selected value onto a field in form1. I changed this Dim MyForm2...
3
by: Karan | last post by:
I am calling finalize when form2 loads and deactivates form1 which closes form1. However, same thing is not happening in form2 because finalize is already called. Does anybody has solution to it....
5
by: lukasmazur | last post by:
Hi I have a problem with using listBox1. I have a two forms form1 and form2. In form1 are controls listBox1, textBox1 and button witch creating object of class Form2. In class Form2 I create a...
9
by: Alfredo73 | last post by:
Hi, I am writing an application in VB2008 with several forms. From Form1 I open a new form with me.hide() and then form2.showdialog(). The system works but in form2 the application runs without...
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
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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: 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...

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.