I feel stupid -problems showing a second form (Vb.Net) 
Author Message
 I feel stupid -problems showing a second form (Vb.Net)

I would like to do the same thing as I would have done with the following
Vb6 code :
form2.show
form2.zorder (0)

I want to create a form1 with a button1.
Button1_click is supposed to start up form2.

In a module (former .bas file) I have the following statement
Public WithEvents Skjermbilde2 As New Form2()

In Form1 Button1_click i have the following code :
Skjermbilde2.Show()

This works fine the first time I click on button1 but after closing form2
and clicking once more I get the following error :

An unhandled exception of type 'System.ObjectDisposedException' occurred in
system.windows.forms.dll
Additional information: Cannot access a disposed object named "Form2".

Can anyone help me ?

Jeroen Schi?tt



Sat, 10 Apr 2004 21:38:03 GMT  
 I feel stupid -problems showing a second form (Vb.Net)
Jeroen,

Quote:
>In a module (former .bas file) I have the following statement
>Public WithEvents Skjermbilde2 As New Form2()

Change that to

Public WithEvents Skjermbilde2 As Form2

And then make sure it's instantiated before calling Show:

If Skjermbilde2 Is Nothing Then Skjermbilde2 = New Form2
Skjermbilde2.Show()

Mattias

===
Mattias Sj?gren (VB MVP)

http://www.msjogren.net/dotnet/



Sun, 11 Apr 2004 01:04:19 GMT  
 I feel stupid -problems showing a second form (Vb.Net)

Quote:
>And then make sure it's instantiated before calling Show:

>If Skjermbilde2 Is Nothing Then Skjermbilde2 = New Form2
>Skjermbilde2.Show()

Oops, that should be

If Skjermbilde2 Is Nothing OrElse Skjermbilde2.IsDisposed Then
  Skjermbilde2 = New Form2
End If
Skjermbilde2.Show()

Mattias

===
Mattias Sj?gren (VB MVP)



Mon, 12 Apr 2004 00:16:36 GMT  
 I feel stupid -problems showing a second form (Vb.Net)
Thank you very much !!
It worked..

Do you/anyone know why the IsDisposed (function or property ??) is not in
the list when I type form1 DOT ctrl space...
Most methods and propeties are listed but not the IsDisposed method or
property.

Mvh Jeroen


Quote:
> >And then make sure it's instantiated before calling Show:

> >If Skjermbilde2 Is Nothing Then Skjermbilde2 = New Form2
> >Skjermbilde2.Show()

> Oops, that should be

> If Skjermbilde2 Is Nothing OrElse Skjermbilde2.IsDisposed Then
>   Skjermbilde2 = New Form2
> End If
> Skjermbilde2.Show()

> Mattias

> ===
> Mattias Sj?gren (VB MVP)



Mon, 12 Apr 2004 14:21:01 GMT  
 I feel stupid -problems showing a second form (Vb.Net)
Thank you very much !!

It worked..

Do you/anyone know why the IsDisposed (function or property ??) is not in
the list when I type form1 DOT ctrl space...

Most methods and propeties are listed but not the IsDisposed method or
property.

Mvh Jeroen


Quote:
> >And then make sure it's instantiated before calling Show:

> >If Skjermbilde2 Is Nothing Then Skjermbilde2 = New Form2
> >Skjermbilde2.Show()

> Oops, that should be

> If Skjermbilde2 Is Nothing OrElse Skjermbilde2.IsDisposed Then
>   Skjermbilde2 = New Form2
> End If
> Skjermbilde2.Show()

> Mattias

> ===
> Mattias Sj?gren (VB MVP)



Mon, 12 Apr 2004 14:28:04 GMT  
 I feel stupid -problems showing a second form (Vb.Net)
Jeroen,

Quote:
>Do you/anyone know why the IsDisposed (function or property ??) is not in
>the list when I type form1 DOT ctrl space...

It is for some reason considered an "advanced member", and therefore
hidden by default. You can show all of these by selecting Tools |
Options... | Text Editor | All Languages or Basic and then clear the
Hide advanced members checkbox.

Mattias

===
Mattias Sj?gren (VB MVP)



Wed, 14 Apr 2004 22:15:29 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. tabbing problems when showing .net form form vb6

2. exception on form.show (vb.Net windows forms)

3. I feel so stupid, but.....

4. I feel stupid: "Too few parameters..."

5. i feel stupid, help me!

6. Feeling really stupid (vb6 question)

7. Feeling Stupid

8. How to show second form from table click event

9. Form.show command in VB.NET

10. loading/showing forms in vb.net

11. how to show a form in vb.net

12. vb.net showing a form after hiding it

 

 
Powered by phpBB® Forum Software