473,467 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Show Hidden Form

How do I Get a ref to my hidden Object like a Form1 When I try to Show the
Form1 from Form2 I can not get a reference to the same instance.
I can Show New Form1's but I cant unhide The one I Hid
Thanks again for the Imagelist Answer. it worked

Nov 21 '05 #1
17 4740
Jim,

Can you show some code, because this seems a little bit strange.
A form can be used as MDI child, MDI parent, with show and showdialog.
All have different ways of using them (getting the parents and the
children).

Cor
Nov 21 '05 #2
Not MDI
in vb6 Code would be.
If you have two Forms Form1 and Form2 and you startup with Form1

Private Sub Button1_Click() '"Button on form1"
Form2.Show
me.Hide
End Sub

Private Sub Button1_Click() "Button on form2
Form1.Show ' Form1 would show with any info entered on the form before
I Called Hide.
Unload Me
End Sub

In .net I have to Dim Form2 as New Form2
Form2.Show
My ? is If I hide an instance of Form1 or Form2 How can I access the Hidden
Form. And not a New Instance of it.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:Of****************@TK2MSFTNGP09.phx.gbl...
Jim,

Can you show some code, because this seems a little bit strange.
A form can be used as MDI child, MDI parent, with show and showdialog.
All have different ways of using them (getting the parents and the
children).

Cor

Nov 21 '05 #3
Jim,

There are a lot of posibilities for this, however this is in my opinon the
most easy one in this case.

\\\
Me.Hide()
Dim frm2 As New Form2
frm2.ShowDialog(me)
frm2.Dispose()
Me.Show()
///

I hope this helps?

Cor
Nov 21 '05 #4
I just Started using MDI in .net Im Having The same Problem ,not Calling a
hidden form The problem is only getting 1 instance of form2.
To show a child or in a non-MDI app to show a form do I have to (Dim frm2 as
NEW? Form2) I only want One Form2 & One Form3 and so on .
Can I call a form2 with out the "New" key word. And if not how do I get only
one instance of Form2 in MDI or SDI.
In the Mdi App I can work around it by setting up a boolForm=False To see if
Form1 was loaded Then set it back to false when it closes .

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Of****************@TK2MSFTNGP09.phx.gbl...
Jim,

Can you show some code, because this seems a little bit strange.
A form can be used as MDI child, MDI parent, with show and showdialog.
All have different ways of using them (getting the parents and the
children).

Cor

Nov 21 '05 #5
Thank you that's a way to work around it.
I was hoping there was a way to reference Form 1 from form 2
Dim Form1 As New Form1()

Me.TextBox1.Text = Form1.TextBox1.Text

I can work around this too ,But I wanted to know if I had to.
I know there is no Forms collection in .net and I could make one.
But my ? is simple can I Show a Form2 with out creating a NEW instance of
one Every time I want to show it.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:ei****************@TK2MSFTNGP10.phx.gbl...
Jim,

There are a lot of posibilities for this, however this is in my opinon the
most easy one in this case.

\\\
Me.Hide()
Dim frm2 As New Form2
frm2.ShowDialog(me)
frm2.Dispose()
Me.Show()
///

I hope this helps?

Cor

Nov 21 '05 #6
Jim,

"me" means just "my" or "this.object"

So when you say
dim frm1 as new form1 you say, create from the form1 class an instance
(object)
(The startup has a build in sub main where this happens).

The same is when you say
dim frm2 as new form2

When you would say

dim frm2 as form
dim frm3 as new form3
frm2 = frm3
than frm2 is frm3 however frm3 is as well frm3

Form1, Form2 and Form3 are classes in this
me is an object
frm2 is an objects
frm3 is an objects

In VBclassic is this a little bit mixed up by trying to make it easier.

You understand probably already what I want to say, people who did
VB(classic) are confused by the behaviour as it is now, however is in VBNet
the same as in C# and more other languages.

I thought it would be better to write this than give you an example in this.

I hope it helps something,

Cor
Nov 21 '05 #7
Jim,

There are by the way possibilities to reference the object instanced from
form1 in Frm2, however it is not good practise because Frm2 comes than
directly completly dependend from the Form1 object so when your change
something than you can have the conflicts that OOP should prevents.

Better is in my opinion to pass the value by overloading new or in my
opinion better, properties in Form2 that are filled before the show.

I hope this helps?

Cor
Nov 21 '05 #8
Thank you I totally understand about creating an object from a forms class I
just wanted to know if it was possible to Reference The Object From another
Object. Its for a small app Ill just keep it in VB6 .I just Program for fun
and .net isn't much fun.
I'm starting to think maybe the vb (Classic) people are right. If I did this
for a living I would be pissed.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Ol****************@TK2MSFTNGP09.phx.gbl...
Jim,

"me" means just "my" or "this.object"

So when you say
dim frm1 as new form1 you say, create from the form1 class an instance
(object)
(The startup has a build in sub main where this happens).

The same is when you say
dim frm2 as new form2

When you would say

dim frm2 as form
dim frm3 as new form3
frm2 = frm3
than frm2 is frm3 however frm3 is as well frm3

Form1, Form2 and Form3 are classes in this
me is an object
frm2 is an objects
frm3 is an objects

In VBclassic is this a little bit mixed up by trying to make it easier.

You understand probably already what I want to say, people who did
VB(classic) are confused by the behaviour as it is now, however is in VBNet the same as in C# and more other languages.

I thought it would be better to write this than give you an example in this.
I hope it helps something,

Cor

Nov 21 '05 #9
Jim,

I know you position in this and you are not the first, I even remember the
answer from Noozer on a previous message from you.

And when you see how much I post than you would understand that that means
that this is extra ordinary. However it is computing so I can be wrong.

Not something angry of course, just that we should not take everything to
serious.

:-)

Cor
Nov 21 '05 #10
Hi Jim!

I used to be a VBClassic programmer and I have to say that dotnet is much
more fun. I also only program for fun and I would never go back to VBClassic
to now.

I know this is not exactly your scenario, but hopefully, it will help you do
what you want.

You have a Form2 which you wish to hide and show from your MDI MainForm and
only have one Instance.
When the form is closed you can no longer access it because it has been
disposed. You wish the form to hide rather than close so that it can
continue to be used by your application.

It's very simple, but slightly different to the way you would do it in
VBClassic.

\\\
Private WithEvents MyForm2 as New Form2

Protected Sub MainForm_Load(...) Handles MyBase.Load
MyForm2.MDIParent = Me
End Sub

Private Sub SomeButton_Click(...) Handles SomeButton.Click
MyForm2.Visible = True
End Sub

Protected Sub MyForm2_Closing(...)Handles MyForm2.Closing
MyForm2.Visible = False
e.Cancel = True
End Sub
///

Another method you could use is to add a module to your project.

\\\
Module FormObjects

Public WithEvents MyForm1 As New Form1
Public WithEvents MyForm2 As New Form2

Private Sub MyForm_Closing(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) _
Handles MyForm1.Closing,
MyForm2.Closing
DirectCast(Sender,Form).Visible = False
e.Cancel = True
End Sub

End Module
///

Now MyForm1 and MyForm2 can be accessed from any form in your app.

Is this the sort of thing you were looking for?

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jim Burns" <Ji****@comcast.net> wrote in message
news:Xc********************@comcast.com...
Thank you I totally understand about creating an object from a forms class
I
just wanted to know if it was possible to Reference The Object From
another
Object. Its for a small app Ill just keep it in VB6 .I just Program for
fun
and .net isn't much fun.
I'm starting to think maybe the vb (Classic) people are right. If I did
this
for a living I would be pissed.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Ol****************@TK2MSFTNGP09.phx.gbl...
Jim,

"me" means just "my" or "this.object"

So when you say
dim frm1 as new form1 you say, create from the form1 class an instance
(object)
(The startup has a build in sub main where this happens).

The same is when you say
dim frm2 as new form2

When you would say

dim frm2 as form
dim frm3 as new form3
frm2 = frm3
than frm2 is frm3 however frm3 is as well frm3

Form1, Form2 and Form3 are classes in this
me is an object
frm2 is an objects
frm3 is an objects

In VBclassic is this a little bit mixed up by trying to make it easier.

You understand probably already what I want to say, people who did
VB(classic) are confused by the behaviour as it is now, however is in

VBNet
the same as in C# and more other languages.

I thought it would be better to write this than give you an example in

this.

I hope it helps something,

Cor


Nov 21 '05 #11
> Handles MyForm1.Closing,
MyForm2.Closing


I messed up on the LineWrap:

Handles MyForm1.Closing, MyForm2.Closing

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
Nov 21 '05 #12
Ill try It I guess then maybe ill understand it.

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:e5****************@TK2MSFTNGP14.phx.gbl...
Handles MyForm1.Closing,
MyForm2.Closing


I messed up on the LineWrap:

Handles MyForm1.Closing, MyForm2.Closing

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


Nov 21 '05 #13
Couldn't get it to work I think the answer to my? is NO.
You cant reference The Running instance of a form or its controls like in
vb6.
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:e5****************@TK2MSFTNGP14.phx.gbl...
Handles MyForm1.Closing,
MyForm2.Closing


I messed up on the LineWrap:

Handles MyForm1.Closing, MyForm2.Closing

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


Nov 21 '05 #14
It's not the same as VB6, don't expect to write VB6 code for VB.Net.

Try to post a simple example of what you are trying to do.

With my module Example you can access any control on either MyForm1 or
MyForm2 from any other form.
In order to access the instance of a form you must set a reference to it.
In the module example I created the variable MyForm1 and set it to a new
Instance of Form1 and similar with MyForm2.

You can then click Button1 on the Instance of Form1 from any other form like
so:
\\\
MyForm1.Button1.PerformClick()
///

What was it that you could not get to work?

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jim Burns" <Jim@Home> wrote in message
news:Q4********************@comcast.com...
Couldn't get it to work I think the answer to my? is NO.
You cant reference The Running instance of a form or its controls like in
vb6.
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote
in
message news:e5****************@TK2MSFTNGP14.phx.gbl...
> Handles MyForm1.Closing,
> MyForm2.Closing


I messed up on the LineWrap:

Handles MyForm1.Closing, MyForm2.Closing

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


Nov 21 '05 #15
I new there had to be a simple way to only have one instance of every form
in your app and be able to effect the form and controls exactly like in vb6.
So I Finally figured out an easy way to do it.

Module Module1

Public WithEvents frm1 As New Form1()

Public WithEvents frm2 As New Form2()

Public jim As String

Public Sub main()

Application.Run(frm1)

End Sub

End Module

__________________________________________________ __________________________
_________

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm2.Show()

Me.Hide()

End Sub

_________________"Code in
Form1_____________________________________________ __________________________
_______

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm1.Visible = True

End Sub

________________"Code in
Forn2_____________________________________________ __________________________
_____________

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:eI***************@TK2MSFTNGP11.phx.gbl...
It's not the same as VB6, don't expect to write VB6 code for VB.Net.

Try to post a simple example of what you are trying to do.

With my module Example you can access any control on either MyForm1 or
MyForm2 from any other form.
In order to access the instance of a form you must set a reference to it.
In the module example I created the variable MyForm1 and set it to a new
Instance of Form1 and similar with MyForm2.

You can then click Button1 on the Instance of Form1 from any other form like so:
\\\
MyForm1.Button1.PerformClick()
///

What was it that you could not get to work?

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jim Burns" <Jim@Home> wrote in message
news:Q4********************@comcast.com...
Couldn't get it to work I think the answer to my? is NO.
You cant reference The Running instance of a form or its controls like in vb6.
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote
in
message news:e5****************@TK2MSFTNGP14.phx.gbl...
> Handles MyForm1.Closing,
> MyForm2.Closing

I messed up on the LineWrap:

Handles MyForm1.Closing, MyForm2.Closing

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html




Nov 21 '05 #16
Didnt need to use WithEvents Key Word
"Jim Burns" <Jim@Home> wrote in message
news:Xt********************@comcast.com...
I new there had to be a simple way to only have one instance of every form
in your app and be able to effect the form and controls exactly like in vb6. So I Finally figured out an easy way to do it.

Module Module1

Public WithEvents frm1 As New Form1()

Public WithEvents frm2 As New Form2()

Public jim As String

Public Sub main()

Application.Run(frm1)

End Sub

End Module

__________________________________________________ __________________________ _________

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm2.Show()

Me.Hide()

End Sub

_________________"Code in
Form1_____________________________________________ __________________________ _______

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

frm1.Visible = True

End Sub

________________"Code in
Forn2_____________________________________________ __________________________ _____________

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in message news:eI***************@TK2MSFTNGP11.phx.gbl...
It's not the same as VB6, don't expect to write VB6 code for VB.Net.

Try to post a simple example of what you are trying to do.

With my module Example you can access any control on either MyForm1 or
MyForm2 from any other form.
In order to access the instance of a form you must set a reference to it.
In the module example I created the variable MyForm1 and set it to a new
Instance of Form1 and similar with MyForm2.

You can then click Button1 on the Instance of Form1 from any other form

like
so:
\\\
MyForm1.Button1.PerformClick()
///

What was it that you could not get to work?

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jim Burns" <Jim@Home> wrote in message
news:Q4********************@comcast.com...
Couldn't get it to work I think the answer to my? is NO.
You cant reference The Running instance of a form or its controls like

in vb6.
"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:e5****************@TK2MSFTNGP14.phx.gbl...
> > Handles MyForm1.Closing,
> > MyForm2.Closing
>
> I messed up on the LineWrap:
>
> Handles MyForm1.Closing, MyForm2.Closing
>
> --
> Mick Doherty
> http://dotnetrix.co.uk/nothing.html
>
>
>




Nov 21 '05 #17
I'm glad you got it working.
I used WithEvents in the original example so I could intercept the Closing
of the Forms Instance and hide it, instead of close it, when a user clicked
on the close button. Once the forms instance has been closed, it is disposed
and you can no longer use it.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"Jim Burns" <Jim@Home> wrote in message
news:DL********************@comcast.com...
Didnt need to use WithEvents Key Word

Nov 21 '05 #18

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

Similar topics

11
by: Jack | last post by:
I want to display a table on a page based on whether a button is pressed or not. I'm new at php so I'm sure I'm making a basic mistake. Here's what I am trying. My thought was that $show_summary...
13
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
9
by: sergio | last post by:
Hi all, I have created the following script that will show/hide a menu based on checkboxes. It works fine in Opera but not on IE6! Does anybody knows a workaround this problem? Thanks for your...
5
by: Zambien | last post by:
Hi all, Here's my problem. I have tables that are using the menu/submenu idea for hiding rows. This works fine in IE (of course) and does show/hide correctly in netscape, but as soon as the...
3
by: veganeater | last post by:
Hi, I'm wondering if there's a way that I can select which <div> to show based on the user's selection from a dropdown/listbox form. <form name="form1" method="post" action=""> <select...
4
by: jerryyang_la1 | last post by:
I've found this script that allows be to hide/show form elements.. <script language="JavaScript"><!-- var toggle = true; function show(object) { if (document.layers && document.layers)...
5
by: Susan | last post by:
I have an application. When a user minimizes it it hides itselfs but stays activate in the system tray. Since it is hidden the user may think that they have exited the application and now may...
1
by: Richard | last post by:
Hello there, I have a form that is called from a Sub Main procedure using application.run(Form1). On my main form there is a button to open an instance of Form2 and then at the same time hide...
3
by: Merlin | last post by:
Hi there, I am trying to create a form with an dynamic field that can be shown or hidden. As I saw for example on google it is possible with JS to show a layer and move the content underneath...
0
by: BcNexus | last post by:
Hello all, The search function of this forum isn't working although I found a similar question on the forum using Google, but the replies don't help me. So, forgive me please if this has been...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.