471,853 Members | 916 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

Creating and showing forms

I have been working on an application, which to this point has only involved
one Windows Form. I need to create another one; but on the Project menu,
there are two options: "Add Windows Form" and "Add Inherited Form."

I don't know which one to use. Also, once I choose one of those two options,
how can I show the second form when a user clicks a button in the first
form? Thanks in advance.
Nov 20 '05 #1
8 1244
"jy836" <mo***@nospam.com> schrieb
I have been working on an application, which to this point has only
involved one Windows Form. I need to create another one; but on the
Project menu, there are two options: "Add Windows Form" and "Add
Inherited Form."

I don't know which one to use. Also, once I choose one of those two
options, how can I show the second form when a user clicks a button
in the first form? Thanks in advance.

http://msdn.microsoft.com/library/en...mToProject.asp
http://msdn.microsoft.com/library/en...delessForm.asp

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

"jy836" <mo***@nospam.com> wrote in message
news:gVAUb.182181$Rc4.1344808@attbi_s54...
I have been working on an application, which to this point has only involved one Windows Form. I need to create another one; but on the Project menu,
there are two options: "Add Windows Form" and "Add Inherited Form."

I don't know which one to use. Also, once I choose one of those two options, how can I show the second form when a user clicks a button in the first
form? Thanks in advance.


Someone else gave you a reference for adding forms / showing them.

As for which option to choose, between "Add Windows Form" and "Add Inherited
Form", well, if I say that all windows forms are classes and the choice is
still not clear, I would highly suggest that you read up and make sure that
you fully understand inheritence and general .NET class fundamentals. I am
afraid that without a firm grasping of these concepts, pruducing effecient
code is nearly impossible.

Nov 20 '05 #3
Cor
Hi Jy,

In your situation, just add form

And to use it put in your form1 something as
dim frm as form2
frm.showdialog
frm.dispose

I hope this helps,

Cor
Nov 20 '05 #4

let your current form be form1 and the newly created form
be form2 which you add as a new form.
in the onclick event of your command button to show this
form add this code:
dim frx as new form2
frx.show
this will show the new form form2 once the button is
clicked !
-----Original Message-----
I have been working on an application, which to this point has only involvedone Windows Form. I need to create another one; but on the Project menu,there are two options: "Add Windows Form" and "Add Inherited Form."
I don't know which one to use. Also, once I choose one of those two options,how can I show the second form when a user clicks a button in the firstform? Thanks in advance.
.

Nov 20 '05 #5
"ziad dodin" <do****@cyberia.jo> wrote in message
news:ba****************************@phx.gbl...

let your current form be form1 and the newly created form
be form2 which you add as a new form.
in the onclick event of your command button to show this
form add this code:
dim frx as new form2
frx.show
this will show the new form form2 once the button is
clicked !
-----Original Message-----
I have been working on an application, which to this

point has only involved
one Windows Form. I need to create another one; but on

the Project menu,
there are two options: "Add Windows Form" and "Add

Inherited Form."

I don't know which one to use. Also, once I choose one of

those two options,
how can I show the second form when a user clicks a

button in the first
form? Thanks in advance.
.


Thanks for all of your responses. With your help, I've gotten the forms up
and running. I'm consistently having problems referencing controls on one
form from another form, though. Is there a simple way to do this? Thanks.
Nov 20 '05 #6
Hi,

Something definitely needs to be placed on the .Net box that explains this
:-) Lots of people are missing a basic point which seems to lead them down
the wrong path. Consider that a "form" that you create is a Class. If you
defined any other class with properties and methods you would expect
(normally) to instantiate one, you would refer to the properties using dot
notation, you'd recognize that you couldn't see any private members of the
class unless you had public accessors.

It isn't different for classes inheriting from System.Windows.Forms

Does this help?
"jy836" <mo***@nospam.com> wrote in message
news:OgRUb.184792$Rc4.1410842@attbi_s54...
"ziad dodin" <do****@cyberia.jo> wrote in message
news:ba****************************@phx.gbl...

let your current form be form1 and the newly created form
be form2 which you add as a new form.
in the onclick event of your command button to show this
form add this code:
dim frx as new form2
frx.show
this will show the new form form2 once the button is
clicked !
-----Original Message-----
I have been working on an application, which to this

point has only involved
one Windows Form. I need to create another one; but on

the Project menu,
there are two options: "Add Windows Form" and "Add

Inherited Form."

I don't know which one to use. Also, once I choose one of

those two options,
how can I show the second form when a user clicks a

button in the first
form? Thanks in advance.
.


Thanks for all of your responses. With your help, I've gotten the forms up
and running. I'm consistently having problems referencing controls on one
form from another form, though. Is there a simple way to do this? Thanks.

Nov 20 '05 #7
"Tom Leylan" <ge*@iamtiredofspam.com> wrote in message
news:OJ**************@TK2MSFTNGP11.phx.gbl...
Hi,

Something definitely needs to be placed on the .Net box that explains this
:-) Lots of people are missing a basic point which seems to lead them down the wrong path. Consider that a "form" that you create is a Class. If you defined any other class with properties and methods you would expect
(normally) to instantiate one, you would refer to the properties using dot
notation, you'd recognize that you couldn't see any private members of the
class unless you had public accessors.

It isn't different for classes inheriting from System.Windows.Forms

Does this help?


Thanks for your reply. Maybe I should explain what it is I'm trying to do.
:-) I have a form titled MainForm (the one that is automatically placed in
any VB Windows Application project, but I renamed it), and another new one
called PrefsForm (a form used for setting user preferences). I created the
new form (PrefsForm) by selecting "Add Windows Form" from the Project menu.

When I click on a menu in MainForm, this is the code that is executed:

Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem8.Click
Dim Prefs As New PrefsForm
Prefs.ShowDialog()
End Sub

What I want to do is when the user types a path and filename of a database
into a text box on PrefsForm, the ConnectionString of OleDbConnection1
(which is on MainForm) will be changed accordingly. But I can't seem to find
a way to access the OleDbConnection1 control on MainForm from PrefsForm.
Hope this makes sense...thanks for your help!
Nov 20 '05 #8
"jy836" <mo***@nospam.com> wrote in message
news:RFSUb.185196$Rc4.1414107@attbi_s54...
Thanks for your reply. Maybe I should explain what it is I'm trying to do.


Generally speaking explanations usually do help :-) In this case the answer
is... "you don't want to do it that way." Problem solved :-)

Seriously if you "really wanted" to have your PrefsForm interact with
controls on your main form you could pass along a reference to the main
form... again consider what you would do if these weren't forms but were any
other object which you happened to be working with. This could be done in
the constructor of PrefsForm for instance. You could also set it up to just
the control along. But neither case is ideal.

Rather when your main form receives control again have it get the
information out of PrefsForm. After the ShowDialog you can add code that
access it. Note that you still have a reference at that time. The form
can't be seen but it exists.

As a third alternative you can create a single public class that
encapsulates all the user preference information and both your main form and
the PresForm can reference it. Doing it that way would mean you wouldn't
have to come up with some scheme to pass along all the current user
preferences if they select the PrefsForm again.

Tom


Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Daniel Hill | last post: by
2 posts views Thread by Ludovic SOEUR | last post: by
1 post views Thread by Henry | last post: by
5 posts views Thread by Randel Bjorkquist | last post: by
3 posts views Thread by Torben Laursen | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

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.