Form hides directly after start

G

Guest

Hi

In my program i open another form after I have done some calculations
I have done this manually so far. All works fine

Now I try to open the form automatically, when the calculations are done. When I do so, the form is just visible for a millisecond, and the hides again. All the startup code in the form is executed. I can trace it, and all seem to be fine. But when the procedure that opened the form is finished, the form dissapeares

Is there anyone who has any idea on why this could happen? Or any tips for how I can find out whats causing it

This works
private sub openFrm(
Dim FormDisplay As New Displa
FormDisplay.Show(
end sub

But when placing those two lines in another, shared sub, the FormDisplay dissappeares when the shared sub is completed. (Or rather when the subs calling that shared sub is completed.

Do I have to select FormDisplay as the active form or something like that

Lots of thanks in advance
/Danie
 
B

Bob Powell [MVP]

FormDisplay is declared in the scope of the subroutine. When the subroutine
ends, the form is disposed and so closes.

Declare the form at class scope and it'll stay there.

--
Bob Powell [MVP]
Visual C#, System.Drawing

All you ever wanted to know about ListView custom drawing is in Well Formed.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

Daniel Strigard said:
Hi.

In my program i open another form after I have done some calculations.
I have done this manually so far. All works fine.

Now I try to open the form automatically, when the calculations are done.
When I do so, the form is just visible for a millisecond, and the hides
again. All the startup code in the form is executed. I can trace it, and all
seem to be fine. But when the procedure that opened the form is finished,
the form dissapeares.
Is there anyone who has any idea on why this could happen? Or any tips for
how I can find out whats causing it?
This works:
private sub openFrm()
Dim FormDisplay As New Display
FormDisplay.Show()
end sub

But when placing those two lines in another, shared sub, the FormDisplay
dissappeares when the shared sub is completed. (Or rather when the subs
calling that shared sub is completed.)
 
G

Guest

Thanks for the reply Bob

You're right. That must have caused the problem
I managed to solve it by using ShowDialog instead of just Show

/Daniel
 
H

Herfried K. Wagner [MVP]

* =?Utf-8?B?RGFuaWVsIFN0cmlnYXJk?= said:
You're right. That must have caused the problem.
I managed to solve it by using ShowDialog instead of just Show.

I think your application is loosing its message loop, have a look at
'Application.Run' in the documentation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top