473,394 Members | 2,071 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,394 software developers and data experts.

What is the exact procedure to show/hide forms?

Hai all,

I've two or more forms on my app.
My requirement is, Have to show the first form asa the user press a button
have to hide the first form and show the second form. If the user press the
escape key on second form, this should be hidded and should show the first
form.... Can some one guide me how to achive this... (MUST USE SHOW & HIDE
FORM PROPERTIES). I tried to achive this using the below code but when i
check the Windows->Task Manager for each and every form changes it's eating
up memory and it's not getting down.

On Form1 :-
Button1_Click()
Dim Form2 as new Form2
Form2.show()

On Form2 :-
Dim Form1 as new Form1
Form1.show()

Thanks in advance.
Ajai
Jul 21 '05 #1
2 2457
Cor
Hi Ajai,

A sample with even 3 forms

Hi x

\\\form 1 needs 2 buttons and a label the other forms only a button to run
it.
Option Strict On
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
#End Region
Private WithEvents frm2 As New Form2
Private WithEvents frm3 As New Form3
Private myActiveForm As Integer
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
myActiveForm = 2
frm2.Show()
me.Hide()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
myActiveForm = 3
frm3.Show()
me.Hide()
End Sub
Private Sub frm2_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm2.VisibleChanged,
frm3.VisibleChanged
Me.Show()
Me.Label1.Text = "Return form = " & myActiveForm.ToString
End Sub
End Class
///
\\\
Public Class Form2
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
End Sub
End Class
///
\\\
Public Class Form3
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
End Sub
End Class
///

I hope this helps a little bit?

Cor


I've two or more forms on my app.
My requirement is, Have to show the first form asa the user press a button
have to hide the first form and show the second form. If the user press the escape key on second form, this should be hidded and should show the first
form.... Can some one guide me how to achive this... (MUST USE SHOW & HIDE
FORM PROPERTIES). I tried to achive this using the below code but when i
check the Windows->Task Manager for each and every form changes it's eating up memory and it's not getting down.

Jul 21 '05 #2
There are several ways of going about doing this. Two of them are
here...

' Check if an instance of a form already exists... and if yes, try to
use it rather than creating a new one.

Declare form object variables at module level and try to dispose them
when closing the form.

On the Form1...

Dim objForm2 as Form2

Public Sub Button1_Click(...)
If (objForm2 is Nothing) objForm2 = new Form2()
objForm2.Show()
Me.Visible = False ' you could also call its Hide method.
End Sub

On Form2...

Dim objForm1 as Form1

Public Sub Button1_Click(...)
If (objForm1 is Nothing) objForm1 = new Form1()
objForm1.Show()
Me.Visible = False
End Sub
The second approach is to close the other form everytime you try to show
a new form. When you close a form, try to set that instance of the form to
Nothing either in the Closing event or Dispose method which will be called
by the Garbage Collector.

Hope this was helpful.

-Azhagan.
"Ajai Kumar .R" <so*****@somewhere.com> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl...
Hai all,

I've two or more forms on my app.
My requirement is, Have to show the first form asa the user press a button
have to hide the first form and show the second form. If the user press the escape key on second form, this should be hidded and should show the first
form.... Can some one guide me how to achive this... (MUST USE SHOW & HIDE
FORM PROPERTIES). I tried to achive this using the below code but when i
check the Windows->Task Manager for each and every form changes it's eating up memory and it's not getting down.

On Form1 :-
Button1_Click()
Dim Form2 as new Form2
Form2.show()

On Form2 :-
Dim Form1 as new Form1
Form1.show()

Thanks in advance.
Ajai

Jul 21 '05 #3

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

Similar topics

3
by: Nathan | last post by:
I read an earlier post from Gary and answered by Peter Huang concerning closing one form and showing another. I need to do the same thing in my application, but the code Peter gave didn't work for...
2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
21
by: StriderBob | last post by:
Situation : FormX is mdi child form containing 2 ListViews ListView1 contains a list of table names and 4 sub items with data about each table. ListView2 contains a list of the columns on each...
0
by: question | last post by:
Hi! I have a requirement where I need to display multiple forms one after the other like a slide show. These are in the same application. Basicall on selection of a menu item it should start...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
4
by: JohnnyDeep | last post by:
I am trying to create a store proc that contain a create index with the cluster option and I receive DB21034E The command was processed as an SQL statement because it was not a valid Command...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
8
by: watkinsdev | last post by:
Hi, I have created a mesh class in visual studio 6.0 c++. I can create a device, render objects and can edit the objects by for instancnce selecting a cluster of vertices and processing the...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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...

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.