473,378 Members | 1,347 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,378 software developers and data experts.

creating a vb.net project with multiple forms

Don
hi

in the past (vb 5.0) is used to create applications with multiple forms. i would hide and/or show the appropriate form depending on user input. now i'm using vb.net (still getting used to it) and can not figure out how to hide and show forms. my project presently has a few forms but i can only the startup form is visible. i can't hide the startup form or show the other forms. i would like to hide a form when a button is pressed and then show another

thanks in advance
Nov 22 '05 #1
5 7091

"Don" <am****@ix.netcom.com> wrote in message
news:74**********************************@microsof t.com...
hi:

in the past (vb 5.0) is used to create applications with multiple forms. i would hide and/or show the appropriate form depending on user input. now
i'm using vb.net (still getting used to it) and can not figure out how to
hide and show forms. my project presently has a few forms but i can only
the startup form is visible. i can't hide the startup form or show the
other forms. i would like to hide a form when a button is pressed and then
show another.
thanks in advance


To get used to the procedure, do the following:
Create a simple VB Windows project, then add a second form to it.
Place a label on each form so you can identify which form is displayed.
Place a button on each form.

Place the following code in the Click event procedure of the button on Form1
' create instance of Form2
Dim my2 As New Form2
'Hide current form

Me.Hide()

'Display new instance

my2.ShowDialog()

Place the following code in the Click event procedure of the button on Form2
Dim my1 As New Form1

Me.Hide()

my1.ShowDialog()

Hope this helps.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 22 '05 #2

"Don" <am****@ix.netcom.com> wrote in message
news:74**********************************@microsof t.com...
hi:

in the past (vb 5.0) is used to create applications with multiple forms. i would hide and/or show the appropriate form depending on user input. now
i'm using vb.net (still getting used to it) and can not figure out how to
hide and show forms. my project presently has a few forms but i can only
the startup form is visible. i can't hide the startup form or show the
other forms. i would like to hide a form when a button is pressed and then
show another.
thanks in advance


To get used to the procedure, do the following:
Create a simple VB Windows project, then add a second form to it.
Place a label on each form so you can identify which form is displayed.
Place a button on each form.

Place the following code in the Click event procedure of the button on Form1
' create instance of Form2
Dim my2 As New Form2
'Hide current form

Me.Hide()

'Display new instance

my2.ShowDialog()

Place the following code in the Click event procedure of the button on Form2
Dim my1 As New Form1

Me.Hide()

my1.ShowDialog()

Hope this helps.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 22 '05 #3
Hi Don,

There are in VB.net a lot of methods to do that.

Peter did show you a method with a dialogform, it is not real hiding because
the dialogform is everytime new instanced, so the information on it will be
lost. Here a sample with 3 forms which are all the time active, although
form1 is the major form. As a third major form there is the MDI form, where
in a formcontainer can be a lot of child forms.

Most classic VB programmers or the ones comming from C are using a
application.start module, however that is not really necassery in VB.net
because that is build in the form class itself.

I hope this helps?

Cor

\\\form1
Private WithEvents frm3 As New Form3
Private WithEvents frm2 As New Form2
Private Sub frm2_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm2.VisibleChanged
If frm2.inputfield <> "" Then
Me.Show()
Me.Label1.Text = frm2.inputfield
frm2.Dispose()
End If
End Sub
Private Sub frm3_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm3.VisibleChanged
If frm3.inputfield <> "" Then
Me.Show()
Me.Label1.Text = frm3.inputfield
frm3.Dispose()
End If
End Sub

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
frm3.Show()
frm3.TopLevel = True
frm2.Show()
frm2.TopLevel = True
End Sub
///
\\\form2 and 3 the same
Public inputfield As String
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

inputfield = "sometext"
Me.Hide()
End Sub
///

Nov 22 '05 #4
Hi Don,

There are in VB.net a lot of methods to do that.

Peter did show you a method with a dialogform, it is not real hiding because
the dialogform is everytime new instanced, so the information on it will be
lost. Here a sample with 3 forms which are all the time active, although
form1 is the major form. As a third major form there is the MDI form, where
in a formcontainer can be a lot of child forms.

Most classic VB programmers or the ones comming from C are using a
application.start module, however that is not really necassery in VB.net
because that is build in the form class itself.

I hope this helps?

Cor

\\\form1
Private WithEvents frm3 As New Form3
Private WithEvents frm2 As New Form2
Private Sub frm2_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm2.VisibleChanged
If frm2.inputfield <> "" Then
Me.Show()
Me.Label1.Text = frm2.inputfield
frm2.Dispose()
End If
End Sub
Private Sub frm3_VisibleChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles frm3.VisibleChanged
If frm3.inputfield <> "" Then
Me.Show()
Me.Label1.Text = frm3.inputfield
frm3.Dispose()
End If
End Sub

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
frm3.Show()
frm3.TopLevel = True
frm2.Show()
frm2.TopLevel = True
End Sub
///
\\\form2 and 3 the same
Public inputfield As String
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click

inputfield = "sometext"
Me.Hide()
End Sub
///

Nov 22 '05 #5
well kid the method to implement multiple form is as follows:
add a class to your project named FormLibrary

code as follows

Public Class FormLibrary
Public Shared Form1 As Form
Public Shared Form2 As Form
End Class
then in the form_load event of the different forms add:

FormLibrary.Form1 = Me

for form2 load event

FormLibrary.Form2 = Me

then u may freely access the form properties from any other form as your old habbit using such syntax

FormLibrary.Form1.Hide()
or
FormLibrary.Form2.Show()

You may also do that with a friend class rather than the public class

further dot Net has brought the feature of creating instances of other forms within other forms

code in form1

Dim fm2 as New Form2
fm2.Show()

BUT dont Confuse it with the above methods coz it creates new instance of the form

to know further about the fundas involved email me

check my sites (my childhood creation)

http://3kd.resourcez.com (developed in 2002)
http://humanpsychology.resourcez.com (developed in 2001)
---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 22 '05 #6

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

Similar topics

1
by: Don | last post by:
hi in the past (vb 5.0) is used to create applications with multiple forms. i would hide and/or show the appropriate form depending on user input. now i'm using vb.net (still getting used to it)...
1
by: john sutor | last post by:
I have a main form in a project that launches other forms. How do I ensure that the same form does not get launched twice without killing the orignal form. I other words I need a method to manage...
7
by: Jeff | last post by:
I plan to write a Windows Forms MDI application for a medical office. Users must be able to select a patient and view related information on multiple forms; with1-4 forms opened at the same time...
5
by: c676228 | last post by:
Hi everyone, my colleagues are thinking about have three insurance plans on one asp page: I simplify the plan as follow: text box:number of people plan1 plan2 plan3
5
by: dancole42 | last post by:
I want to create a button that will print multiple forms. Each form is a list of various orders, and there are three separate forms: -Standard Orders -Rush Orders -VIP Rush Orders Each is...
12
by: rents | last post by:
hello all, I have a project due by the end of the this week. with this particular project, we are to use "multiple forms." I'm a little shaky on this concept. So here is the description of the...
3
by: tigger | last post by:
I have a problem with my project. I have multiple forms. In the main form, I'll have to click on a button where by another form will appear. However, I cannot return to my main form without having to...
0
by: Demonweare | last post by:
Beginner Alert! How do I access public members from different classes at runtime? For example, I have a C#.NET project that uses multiple forms and I need to be able to get values from controls...
2
by: =?Utf-8?B?VGFtbXkgTmVqYWRpYW4=?= | last post by:
Hi, I am going to write a large application using Visual Studio C#. I am going to use only one Form as main menu and go to other pages by cliking on next button in each page. I dont want to create...
2
by: Shirisha B | last post by:
How to declare connection string globally while doing a project in multiple forms?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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...

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.