469,581 Members | 1,960 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,581 developers. It's quick & easy.

how do i manage my form instances

Hi,

Does anyone have any example of how i can manage forms in
my application??

I want to be able to reference my form instances that are
currently open from other forms.

why cant i open and close forms as easily as in VB6??

i.e if i have formHomepage open and i click on a link to
open form2 i use

Dim frm2 as new form2
frm2.show

however i wnat to be able to open the same formHomepage
instance from within my frm2 instance.

is there a way to do this? Does anyone have any code
example or managing form instabnces or any useful
articles for vb.net??

i would really appreciate any help

thx
Jul 21 '05 #1
4 1922
Tonya:

I'm not putting down VB6, but there's nothing object oriented about using
things that just exist, that don't need to be instantiated. When you call
close in .NET, it fires .Disposes shortly thereafter and the form is no
longer available. You can choose to override the closing events of your
forms and make them invisible, then instead of calling show make them
visible again. However, you'd need to keep them all scoped and this is not
an approach I'd suggest. Instead, I'd recommend creating objects to hold
those form variables that you need and pass them in to the forms constructor
which you can overload or once the form loads, set whatever properties to
the given object's values.

The whole concept of managing forms is going to be quite different then your
experience with VB6 because forms and many other things are radical
departures form the old way. You can create objects/modules that hold all
of this data and get you wherever you want to be but IMHO, managing specific
forms all over an application is something I'm not sad to see go away.

If you can show me specifically what problem you're having, I'll be glad to
try to help you accomplish what you need.

HTH,

Bill
"Tonya" <s@m> wrote in message
news:02****************************@phx.gbl...
Hi,

Does anyone have any example of how i can manage forms in
my application??

I want to be able to reference my form instances that are
currently open from other forms.

why cant i open and close forms as easily as in VB6??

i.e if i have formHomepage open and i click on a link to
open form2 i use

Dim frm2 as new form2
frm2.show

however i wnat to be able to open the same formHomepage
instance from within my frm2 instance.

is there a way to do this? Does anyone have any code
example or managing form instabnces or any useful
articles for vb.net??

i would really appreciate any help

thx

Jul 21 '05 #2
Hi William,
thx for your input.

what i want to achieve is to be able to show a form
instance that has alreay been opened. When i open my
application formHomepage is opened as the starting form.
On this form i have 4 buttons that open 4 other forms.
When i click a button form2 is displayed and is shown
above formHomepage. However when i try to go back to my
homepage from form2 a new instance of formhomepage is
opened!!! Now i have 2 instances of the same form. This
is not what i want. I want to show the instance that is
already open. This is what i need help coding.

As u have probably guessed i am a beginner to VB.NET and
am finding things very difficult to get used to!!

any help or advise u could give is very much appreciated.

-----Original Message-----
Tonya:

I'm not putting down VB6, but there's nothing object oriented about usingthings that just exist, that don't need to be instantiated. When you callclose in .NET, it fires .Disposes shortly thereafter and the form is nolonger available. You can choose to override the closing events of yourforms and make them invisible, then instead of calling show make themvisible again. However, you'd need to keep them all scoped and this is notan approach I'd suggest. Instead, I'd recommend creating objects to holdthose form variables that you need and pass them in to the forms constructorwhich you can overload or once the form loads, set whatever properties tothe given object's values.

The whole concept of managing forms is going to be quite different then yourexperience with VB6 because forms and many other things are radicaldepartures form the old way. You can create objects/modules that hold allof this data and get you wherever you want to be but IMHO, managing specificforms all over an application is something I'm not sad to see go away.
If you can show me specifically what problem you're having, I'll be glad totry to help you accomplish what you need.

HTH,

Bill
"Tonya" <s@m> wrote in message
news:02****************************@phx.gbl...
Hi,

Does anyone have any example of how i can manage forms in my application??

I want to be able to reference my form instances that are currently open from other forms.

why cant i open and close forms as easily as in VB6??

i.e if i have formHomepage open and i click on a link to open form2 i use

Dim frm2 as new form2
frm2.show

however i wnat to be able to open the same formHomepage
instance from within my frm2 instance.

is there a way to do this? Does anyone have any code
example or managing form instabnces or any useful
articles for vb.net??

i would really appreciate any help

thx

.

Jul 21 '05 #3
Tonya:

If you have code in form1 for instance that Shows form2.....
Button_Click(blah blah) handles button1.click
Dim f as New form2
f.ShowDialog()

Then you close form2, you should be back at Form1. However, if you are
dimming a new Form1 in Form2, you'll have a new form. If Form1 is your
main form, you may well want to make it an MDI form so that no matter what,
you'll always come back to it when you close all of the other windows.

Every time you dim something as New, you have a totally new object. You can
declare a zillion different instances of Form1 that are totally distinct so
you need ot be aware of that when you are calling instances. Also, you may
want to use ShowDialog instead of Show depending on your specific situation,
which will show a form Modally instead of just showing it. In VB6, Form2
always stayed alive and it was never born as such in the code. You could
call its show method from anywhere. However, in VB.NET, let's say you have
Form1 in your project, but you use thsi code alone Form1.Show, it won't work
because it's never been instantiated. And since the form is 'born' it can
die which occurs when it's closed (how it actually dies is another story but
Garbage collection is a whole different issue).

Anyway, I hope I answered your question, but if not, let me know and I'll do
what I can.

HTH,

Bill
"Tonya" <an*******@discussions.microsoft.com> wrote in message
news:0b****************************@phx.gbl...
Hi William,
thx for your input.

what i want to achieve is to be able to show a form
instance that has alreay been opened. When i open my
application formHomepage is opened as the starting form.
On this form i have 4 buttons that open 4 other forms.
When i click a button form2 is displayed and is shown
above formHomepage. However when i try to go back to my
homepage from form2 a new instance of formhomepage is
opened!!! Now i have 2 instances of the same form. This
is not what i want. I want to show the instance that is
already open. This is what i need help coding.

As u have probably guessed i am a beginner to VB.NET and
am finding things very difficult to get used to!!

any help or advise u could give is very much appreciated.

-----Original Message-----
Tonya:

I'm not putting down VB6, but there's nothing object

oriented about using
things that just exist, that don't need to be

instantiated. When you call
close in .NET, it fires .Disposes shortly thereafter and

the form is no
longer available. You can choose to override the

closing events of your
forms and make them invisible, then instead of calling

show make them
visible again. However, you'd need to keep them all

scoped and this is not
an approach I'd suggest. Instead, I'd recommend

creating objects to hold
those form variables that you need and pass them in to

the forms constructor
which you can overload or once the form loads, set

whatever properties to
the given object's values.

The whole concept of managing forms is going to be quite

different then your
experience with VB6 because forms and many other things

are radical
departures form the old way. You can create

objects/modules that hold all
of this data and get you wherever you want to be but

IMHO, managing specific
forms all over an application is something I'm not sad

to see go away.

If you can show me specifically what problem you're

having, I'll be glad to
try to help you accomplish what you need.

HTH,

Bill
"Tonya" <s@m> wrote in message
news:02****************************@phx.gbl...
Hi,

Does anyone have any example of how i can manage forms in my application??

I want to be able to reference my form instances that are currently open from other forms.

why cant i open and close forms as easily as in VB6??

i.e if i have formHomepage open and i click on a link to open form2 i use

Dim frm2 as new form2
frm2.show

however i wnat to be able to open the same formHomepage
instance from within my frm2 instance.

is there a way to do this? Does anyone have any code
example or managing form instabnces or any useful
articles for vb.net??

i would really appreciate any help

thx

.

Jul 21 '05 #4
Hi William,

Is there anyway i can handle my forms as if i were using
VB6?? i.e if I want to be able to refernce the controls
that are on form3 while i am in form2.

Is there no way of referencing an already instantiated
form?

btw, thx for your book recommendation last time on
ADO.NET. it proved very useful :o)
-----Original Message-----
Tonya:

If you have code in form1 for instance that Shows form2.....Button_Click(blah blah) handles button1.click
Dim f as New form2
f.ShowDialog()

Then you close form2, you should be back at Form1. However, if you aredimming a new Form1 in Form2, you'll have a new form. If Form1 is yourmain form, you may well want to make it an MDI form so that no matter what,you'll always come back to it when you close all of the other windows.
Every time you dim something as New, you have a totally new object. You candeclare a zillion different instances of Form1 that are totally distinct soyou need ot be aware of that when you are calling instances. Also, you maywant to use ShowDialog instead of Show depending on your specific situation,which will show a form Modally instead of just showing it. In VB6, Form2always stayed alive and it was never born as such in the code. You couldcall its show method from anywhere. However, in VB.NET, let's say you haveForm1 in your project, but you use thsi code alone Form1.Show, it won't workbecause it's never been instantiated. And since the form is 'born' it candie which occurs when it's closed (how it actually dies is another story butGarbage collection is a whole different issue).

Anyway, I hope I answered your question, but if not, let me know and I'll dowhat I can.

HTH,

Bill
"Tonya" <an*******@discussions.microsoft.com> wrote in messagenews:0b****************************@phx.gbl...
Hi William,
thx for your input.

what i want to achieve is to be able to show a form
instance that has alreay been opened. When i open my
application formHomepage is opened as the starting form.
On this form i have 4 buttons that open 4 other forms.
When i click a button form2 is displayed and is shown
above formHomepage. However when i try to go back to my
homepage from form2 a new instance of formhomepage is
opened!!! Now i have 2 instances of the same form. This
is not what i want. I want to show the instance that is
already open. This is what i need help coding.

As u have probably guessed i am a beginner to VB.NET and
am finding things very difficult to get used to!!

any help or advise u could give is very much appreciated.
>-----Original Message-----
>Tonya:
>
>I'm not putting down VB6, but there's nothing object

oriented about using
>things that just exist, that don't need to be

instantiated. When you call
>close in .NET, it fires .Disposes shortly thereafter and
the form is no
>longer available. You can choose to override the

closing events of your
>forms and make them invisible, then instead of calling

show make them
>visible again. However, you'd need to keep them all

scoped and this is not
>an approach I'd suggest. Instead, I'd recommend

creating objects to hold
>those form variables that you need and pass them in to

the forms constructor
>which you can overload or once the form loads, set

whatever properties to
>the given object's values.
>
>The whole concept of managing forms is going to be
quite different then your
>experience with VB6 because forms and many other things

are radical
>departures form the old way. You can create

objects/modules that hold all
>of this data and get you wherever you want to be but

IMHO, managing specific
>forms all over an application is something I'm not sad

to see go away.
>
>If you can show me specifically what problem you're

having, I'll be glad to
>try to help you accomplish what you need.
>
>HTH,
>
>Bill
>"Tonya" <s@m> wrote in message
>news:02****************************@phx.gbl...
>> Hi,
>>
>> Does anyone have any example of how i can manage
forms in
>> my application??
>>
>> I want to be able to reference my form instances that

are
>> currently open from other forms.
>>
>> why cant i open and close forms as easily as in VB6??
>>
>> i.e if i have formHomepage open and i click on a link

to
>> open form2 i use
>>
>> Dim frm2 as new form2
>> frm2.show
>>
>> however i wnat to be able to open the same

formHomepage >> instance from within my frm2 instance.
>>
>> is there a way to do this? Does anyone have any code
>> example or managing form instabnces or any useful
>> articles for vb.net??
>>
>> i would really appreciate any help
>>
>> thx
>
>
>.
>

.

Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by David Lauberts | last post: by
reply views Thread by RonNanko | last post: by
4 posts views Thread by Tonya | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.