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

Windows Forms Question

Hello,

I'm *just* delving into Windows forms-based programming without the benefit
of any books, etc. I have a background in light ASP.NET work, so forgive me
if this is a really basic question related to Windows GUI.

I've created a "Form1.vb" file in my project, added a menustrip, etc. When a
user clicks on a menu item, how do I get it to show a new form in the same
window?

I'm basically asking how to create a Windows forms application with more
than 1 form. :) All the examples on the internet of this type of programming
typically show one form.

I'm trying to understand how to create a standard UI (i.e. window size,
title, menustrip, etc) and then change the content of the form based on what
the user wants to do.

Thanks. :)

Scott

Sep 21 '08 #1
9 1774
There's a good discussion here:
http://msdn.microsoft.com/en-us/libr...29(VS.71).aspx
Working with Multiple Forms in Visual Basic .NET: Upgrading to .NET

However, your last paragraph seems to contradict the approach described
there - opening different forms (with different content) is one way of
allowing your user to perform different tasks. Changing the content of the
current form is a different way of allowing your user to perform different
tasks. Of course, you can use both procedures within the one application,
but they are different programming techniques.

If you are talking about using a form template so that you are using
different forms but with a consistency in a number of basic controls on the
form, and you don't want to be separately adding and tweaking those repeated
controls, then you are talking about subclassing the form. See
http://msdn.microsoft.com/en-us/libr...13(VS.71).aspx
Windows Forms Inheritance

"Scott Stark" <sc***@webservicesinc.comwrote in message
news:Or**************@TK2MSFTNGP05.phx.gbl...
Hello,

I'm *just* delving into Windows forms-based programming without the
benefit of any books, etc. I have a background in light ASP.NET work, so
forgive me if this is a really basic question related to Windows GUI.

I've created a "Form1.vb" file in my project, added a menustrip, etc. When
a user clicks on a menu item, how do I get it to show a new form in the
same window?

I'm basically asking how to create a Windows forms application with more
than 1 form. :) All the examples on the internet of this type of
programming typically show one form.

I'm trying to understand how to create a standard UI (i.e. window size,
title, menustrip, etc) and then change the content of the form based on
what the user wants to do.

Thanks. :)

Scott
Sep 21 '08 #2
At first I thought you were asking how to make a form similar to MS Access,
where many forms are initated inside the main form. Later it seems to me
that you are describing something more like MS Outlook, which changes
its contents based on what the user wants (email lists, contacts, calendar).

Which is closer to what you are after?

"Scott Stark" <sc***@webservicesinc.comwrote in message
news:Or**************@TK2MSFTNGP05.phx.gbl...
Hello,

I'm *just* delving into Windows forms-based programming without the
benefit of any books, etc. I have a background in light ASP.NET work, so
forgive me if this is a really basic question related to Windows GUI.

I've created a "Form1.vb" file in my project, added a menustrip, etc. When
a user clicks on a menu item, how do I get it to show a new form in the
same window?

I'm basically asking how to create a Windows forms application with more
than 1 form. :) All the examples on the internet of this type of
programming typically show one form.

I'm trying to understand how to create a standard UI (i.e. window size,
title, menustrip, etc) and then change the content of the form based on
what the user wants to do.

Thanks. :)

Scott
Sep 21 '08 #3
Hi Mike,

Thank's for the response. I'm talking about more of an Outlook-style
functionality. If the user chooses something from the left-hand menu, the
"content" pane changes to that particular form.

Scott

"Family Tree Mike" <Fa************@ThisOldHouse.comwrote in message
news:ej*************@TK2MSFTNGP03.phx.gbl...
At first I thought you were asking how to make a form similar to MS
Access,
where many forms are initated inside the main form. Later it seems to me
that you are describing something more like MS Outlook, which changes
its contents based on what the user wants (email lists, contacts,
calendar).

Which is closer to what you are after?

"Scott Stark" <sc***@webservicesinc.comwrote in message
news:Or**************@TK2MSFTNGP05.phx.gbl...
>Hello,

I'm *just* delving into Windows forms-based programming without the
benefit of any books, etc. I have a background in light ASP.NET work, so
forgive me if this is a really basic question related to Windows GUI.

I've created a "Form1.vb" file in my project, added a menustrip, etc.
When a user clicks on a menu item, how do I get it to show a new form in
the same window?

I'm basically asking how to create a Windows forms application with more
than 1 form. :) All the examples on the internet of this type of
programming typically show one form.

I'm trying to understand how to create a standard UI (i.e. window size,
title, menustrip, etc) and then change the content of the form based on
what the user wants to do.

Thanks. :)

Scott
Sep 21 '08 #4
Hi James,

Sub-classing seems to be more along the lines of what I'm looking for. I'll
look into that, but it seems that then I'll be able to make Form1 and Form2
inherit the base controls from, say "BaseForm" and then add the required
functionality to Form1 and Form2.

However, how do I get Form2 to display when the user is looking at Form1?
Form2.Show() would open a new window? I want to "replace" Form1 with Form2
in the same window, if that makes sense.

"James Hahn" <jh***@yahoo.comwrote in message
news:OS**************@TK2MSFTNGP05.phx.gbl...
There's a good discussion here:
http://msdn.microsoft.com/en-us/libr...29(VS.71).aspx
Working with Multiple Forms in Visual Basic .NET: Upgrading to .NET

However, your last paragraph seems to contradict the approach described
there - opening different forms (with different content) is one way of
allowing your user to perform different tasks. Changing the content of
the current form is a different way of allowing your user to perform
different tasks. Of course, you can use both procedures within the one
application, but they are different programming techniques.

If you are talking about using a form template so that you are using
different forms but with a consistency in a number of basic controls on
the form, and you don't want to be separately adding and tweaking those
repeated controls, then you are talking about subclassing the form. See
http://msdn.microsoft.com/en-us/libr...13(VS.71).aspx
Windows Forms Inheritance

"Scott Stark" <sc***@webservicesinc.comwrote in message
news:Or**************@TK2MSFTNGP05.phx.gbl...
>Hello,

I'm *just* delving into Windows forms-based programming without the
benefit of any books, etc. I have a background in light ASP.NET work, so
forgive me if this is a really basic question related to Windows GUI.

I've created a "Form1.vb" file in my project, added a menustrip, etc.
When a user clicks on a menu item, how do I get it to show a new form in
the same window?

I'm basically asking how to create a Windows forms application with more
than 1 form. :) All the examples on the internet of this type of
programming typically show one form.

I'm trying to understand how to create a standard UI (i.e. window size,
title, menustrip, etc) and then change the content of the form based on
what the user wants to do.

Thanks. :)

Scott
Sep 21 '08 #5
Like I said, your second paragraph contadicts your description of what you
are trying to do.

If you subclass a form then you create a new form, with its own design and
functionality, and open and close that form as needed. This can be done as a
selection by the user from a controlling form (dashboard-style) or it can be
in a rotating format, where the user moves from one form to the the next in
a sequence, returning to the start after having completed the task. Because
the forms are subclassed they can be set up to have some predefined
components that are identical from form to form and are maintained at one
location only - the class for the form. You can use modality to require the
user to work on one form at a time, if appropriate. But each task is carried
out in its own form.

The format you are describing involves using one form only, with some
components that are fixed in place and are always visible and enabled and
some components that come and go according to the current task. This is not
subclassing - there is only one form. You are simply dynamically enabling,
disabling, hiding and moving controls on the form to present a form layout
that is relevant to the current task.

I suppose you could do this by using multiple forms, setting them up to have
some common components, and forcing each form to open with the size and
position of the form from which it was started, hiding the startup form each
time. This would fool the user into thinking there was only one form and the
contents simply changed slightly depending on the task. But it seems a bit
pointless to set the project up as multiple forms and then go to all that
trouble to make it look like there's only one.

Or, perhaps you are talking about an MDI form.
http://msdn.microsoft.com/en-us/libr...7x(VS.71).aspx
MDI Changes in Visual Basic .NET

"Scott Stark" <em***@scottstark.comwrote in message
news:ev****************@TK2MSFTNGP05.phx.gbl...
Hi James,

Sub-classing seems to be more along the lines of what I'm looking for.
I'll look into that, but it seems that then I'll be able to make Form1 and
Form2 inherit the base controls from, say "BaseForm" and then add the
required functionality to Form1 and Form2.

However, how do I get Form2 to display when the user is looking at Form1?
Form2.Show() would open a new window? I want to "replace" Form1 with Form2
in the same window, if that makes sense.
Sep 21 '08 #6
Here is code that I am using to control the right panel of a split container
based on an item in a treeview selected in the left panel. The form
contained in the right panel depends on what type of node was selected.
Hopefully this gets you started. The description of "s" should not be too
important other than there is a Type property which the form type needs to
be based upon.

GEDCOM.GEDCOM_55.Section s = (GEDCOM.GEDCOM_55.Section)e.Node.Tag;
splitContainer1.Panel2.Controls.Clear();
if (s == null) return;

if (s.Type == "INDI")
{
IndividualUI ui = new IndividualUI();
ui.TopLevel = false;
splitContainer1.Panel2.Controls.Add(ui);
ui.Dock = DockStyle.Fill;
ui.Show();
}
else if (s.Type == "FAM")
{
FamilyUI ui = new FamilyUI();
ui.TopLevel = false;
splitContainer1.Panel2.Controls.Add(ui);
ui.Dock = DockStyle.Fill;
ui.Show();
}
"Scott Stark" <em***@scottstark.comwrote in message
news:u5****************@TK2MSFTNGP04.phx.gbl...
Hi Mike,

Thank's for the response. I'm talking about more of an Outlook-style
functionality. If the user chooses something from the left-hand menu, the
"content" pane changes to that particular form.

Scott

"Family Tree Mike" <Fa************@ThisOldHouse.comwrote in message
news:ej*************@TK2MSFTNGP03.phx.gbl...
>At first I thought you were asking how to make a form similar to MS
Access,
where many forms are initated inside the main form. Later it seems to me
that you are describing something more like MS Outlook, which changes
its contents based on what the user wants (email lists, contacts,
calendar).

Which is closer to what you are after?

"Scott Stark" <sc***@webservicesinc.comwrote in message
news:Or**************@TK2MSFTNGP05.phx.gbl...
>>Hello,

I'm *just* delving into Windows forms-based programming without the
benefit of any books, etc. I have a background in light ASP.NET work, so
forgive me if this is a really basic question related to Windows GUI.

I've created a "Form1.vb" file in my project, added a menustrip, etc.
When a user clicks on a menu item, how do I get it to show a new form in
the same window?

I'm basically asking how to create a Windows forms application with more
than 1 form. :) All the examples on the internet of this type of
programming typically show one form.

I'm trying to understand how to create a standard UI (i.e. window size,
title, menustrip, etc) and then change the content of the form based on
what the user wants to do.

Thanks. :)

Scott
Sep 21 '08 #7
A form is a window. You can display different content in a form, or
you can create more forms and display them. There is no concept of
replacing one form with another, except for MIDI child windows where
you show one or more child windows in a containing parent window.

The easiest way to display different content in a form is to have two
or more containers (e.g. Panel) in a form, and make one visible at a
time.

On Sun, 21 Sep 2008 06:37:27 -0700, "Scott Stark"
<em***@scottstark.comwrote:
>Hi James,

Sub-classing seems to be more along the lines of what I'm looking for. I'll
look into that, but it seems that then I'll be able to make Form1 and Form2
inherit the base controls from, say "BaseForm" and then add the required
functionality to Form1 and Form2.

However, how do I get Form2 to display when the user is looking at Form1?
Form2.Show() would open a new window? I want to "replace" Form1 with Form2
in the same window, if that makes sense.

"James Hahn" <jh***@yahoo.comwrote in message
news:OS**************@TK2MSFTNGP05.phx.gbl...
>There's a good discussion here:
http://msdn.microsoft.com/en-us/libr...29(VS.71).aspx
Working with Multiple Forms in Visual Basic .NET: Upgrading to .NET

However, your last paragraph seems to contradict the approach described
there - opening different forms (with different content) is one way of
allowing your user to perform different tasks. Changing the content of
the current form is a different way of allowing your user to perform
different tasks. Of course, you can use both procedures within the one
application, but they are different programming techniques.

If you are talking about using a form template so that you are using
different forms but with a consistency in a number of basic controls on
the form, and you don't want to be separately adding and tweaking those
repeated controls, then you are talking about subclassing the form. See
http://msdn.microsoft.com/en-us/libr...13(VS.71).aspx
Windows Forms Inheritance

"Scott Stark" <sc***@webservicesinc.comwrote in message
news:Or**************@TK2MSFTNGP05.phx.gbl...
>>Hello,

I'm *just* delving into Windows forms-based programming without the
benefit of any books, etc. I have a background in light ASP.NET work, so
forgive me if this is a really basic question related to Windows GUI.

I've created a "Form1.vb" file in my project, added a menustrip, etc.
When a user clicks on a menu item, how do I get it to show a new form in
the same window?

I'm basically asking how to create a Windows forms application with more
than 1 form. :) All the examples on the internet of this type of
programming typically show one form.

I'm trying to understand how to create a standard UI (i.e. window size,
title, menustrip, etc) and then change the content of the form based on
what the user wants to do.

Thanks. :)

Scott
Sep 22 '08 #8
Just to clarify, a panel can be a container for a form. This lets you use
the form as both a tradtional form and as something like a user
control or panel within the form. My example in this thread shows
how to dock a form in the panel.

When you dock a form in a panel, you should set the border to none,
and I see I forgot that in my other post.
"Jack Jackson" <jj******@cinnovations.netwrote in message
news:qp********************************@4ax.com...
>A form is a window. You can display different content in a form, or
you can create more forms and display them. There is no concept of
replacing one form with another, except for MIDI child windows where
you show one or more child windows in a containing parent window.

The easiest way to display different content in a form is to have two
or more containers (e.g. Panel) in a form, and make one visible at a
time.

On Sun, 21 Sep 2008 06:37:27 -0700, "Scott Stark"
<em***@scottstark.comwrote:
>>Hi James,

Sub-classing seems to be more along the lines of what I'm looking for.
I'll
look into that, but it seems that then I'll be able to make Form1 and
Form2
inherit the base controls from, say "BaseForm" and then add the required
functionality to Form1 and Form2.

However, how do I get Form2 to display when the user is looking at Form1?
Form2.Show() would open a new window? I want to "replace" Form1 with Form2
in the same window, if that makes sense.

"James Hahn" <jh***@yahoo.comwrote in message
news:OS**************@TK2MSFTNGP05.phx.gbl...
>>There's a good discussion here:
http://msdn.microsoft.com/en-us/libr...29(VS.71).aspx
Working with Multiple Forms in Visual Basic .NET: Upgrading to .NET

However, your last paragraph seems to contradict the approach described
there - opening different forms (with different content) is one way of
allowing your user to perform different tasks. Changing the content of
the current form is a different way of allowing your user to perform
different tasks. Of course, you can use both procedures within the one
application, but they are different programming techniques.

If you are talking about using a form template so that you are using
different forms but with a consistency in a number of basic controls on
the form, and you don't want to be separately adding and tweaking those
repeated controls, then you are talking about subclassing the form. See
http://msdn.microsoft.com/en-us/libr...13(VS.71).aspx
Windows Forms Inheritance

"Scott Stark" <sc***@webservicesinc.comwrote in message
news:Or**************@TK2MSFTNGP05.phx.gbl...
Hello,

I'm *just* delving into Windows forms-based programming without the
benefit of any books, etc. I have a background in light ASP.NET work,
so
forgive me if this is a really basic question related to Windows GUI.

I've created a "Form1.vb" file in my project, added a menustrip, etc.
When a user clicks on a menu item, how do I get it to show a new form
in
the same window?

I'm basically asking how to create a Windows forms application with
more
than 1 form. :) All the examples on the internet of this type of
programming typically show one form.

I'm trying to understand how to create a standard UI (i.e. window size,
title, menustrip, etc) and then change the content of the form based on
what the user wants to do.

Thanks. :)

Scott
Sep 22 '08 #9
Hi Scott:
I'm not the smartest in VB.Net, but one way if you want to replace form1
with form2 is when you set the button on form1 to show form2, you can also
set it to close form1 as well. and if you want form1 to show again when
closing form2, you can do the same thing. show form1 and close form2.

Private Sub btnShowForm2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button13.Click
form2.show()
Me.Close()
End Sub

hope this helps.
Oct 3 '08 #10

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

Similar topics

1
by: KK | last post by:
Windows Forms Inheritance, Incomplete? I was playing around with Windows Forms and found out this Forms Inheritance feature. The moment I saw that, I felt this can be used effectively if the...
6
by: Hamed | last post by:
Hello I have employed as a developer in a software company that its team uses FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to migrate to VS.NET. There is a project...
3
by: Nick | last post by:
I am working a new application...well actually a series of applications for my company. They want internal users to be able to go to a site and everything regarding security is transparent,...
7
by: MounilK | last post by:
Hi all, I am not sure if this is the right NG to post this question. If that's the case please point me to the correct NG. I have a class library(myLib.dll) which has a class(myClass) which has...
2
by: Markus Eßmayr | last post by:
Hello, I'm writing an extension class for the winforms button control using MC++. I created a class, derived from System::Windows::Forms::Button. In my class I want to extend the functionality...
4
by: Andrew | last post by:
Hey all, I would like to preface my question by stating I am still learning ASP.net and while I am confident in the basics and foundation, the more advanced stuff is still a challenge. Ok....
8
by: Alison | last post by:
Hi, Al I am trying to design a user interface which provides both menus and toolbars for some users to click on whatever they want to do, at the same time, I would like to have a console window...
3
by: Neal | last post by:
managed C++ VS 2003 I have a beginner question about windows forms.... I need to call a function when a certain limit has been reached, now with the way VS sets up the .NET windows Form I get...
21
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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,...

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.