Need some help on forms

  • Thread starter Thread starter harrypotter
  • Start date Start date
H

harrypotter

Hey,
YO...., I NEED SOME HELP HERE ! Actually, I got some info from
a good guy called ScottT, but I need more. You see, I'm kind of stuck
in here.

I need to connect two forms. But the problem
is... I don't know the codes. What I wanna do is click a button from
the first form to go to the second form & then click a button from the
second form to go to the third form & then etc etc. Also I wanna have a
certain form which connected to all the other forms & can click a
button from that certain form to go to all the other forms. That's all.
Why can't anybody just help me ?

I'm a newcomer to the field & I need help so
....so ...much.
 
Hi,

Your requirements are vague.

1. What do you mean by "go to"? Do you mean, "show"?
2. What happens to the form with the button after the button is clicked? Does it close?
3. The following is unclear. What do you mean by "go to all other forms"?
Also I wanna have a
certain form which connected to all the other forms & can click a
button from that certain form to go to all the other forms.

You'll have a much better chance of someone helping you if you clear up your requirements. As a "newcomer", a better approach might
be to ask, "Should I code my program in this way, or is there a better way"? That depends on what your program is supposed to do.
Therefore, you might want to mention that as well.
 
Hi,

You should also mention the version of the framework that you are using and the tools that you have at your disposal. i.e. Do you
have Visual Studio.NET 2005?
 
Dave said:
Hi,

You should also mention the version of the framework that you are using and the tools that you have at your disposal. i.e. Do you
have Visual Studio.NET 2005?


Hi Dave,
First of all I would like to thank you, cause you are the
only one who even reply me.

&

No Dave I'm using VB Express Edition 2005 at the moment. But I have
Vishual Studio.NET 2005 with me.


Actually I have several problems :


(01)
I have created 25 different forms for various purposes.
You know with buttons, labels, picture boxes, lists & stuff like that.
Imagine there's a main form with lots & lots of
buttons which I want to connect to all the other forms. What it means
is, when I click the button called A the form called A appears and
then I click the button called B, form B appears, etc,etc.

&

Yes your right I want them to show. I know I can do it by
adding this code to the click event of the main form " FormA.show( )".
The matter is, when I click the button A the form A appears BUT main
form doesn't close. Can you teach me a code which does these two deeds
at the same time.

&

After that I want to connect all these forms like pages of a
book.You know like NEXT & PREVIOUS. It means I want to click a button
in the form A to show the Form B. But I want Form A to close at the
moment the Form B appears & then click a button from the Form B to show
the Form C & to close Form B when the Form C appears, etc, etc.

Can you teach me the right kind of codes which I need in here ????


( 02 )

Also I need the code to go back. It's like this. I'm clicking on
the button called BACK in the form C & I get the form B ( Form B
appears). & I want form C to close, too. You see I want these both
works to happend at once.


Can you teach me the right kind of codes which I need in here
????


(03)
In my Form A there are 3 picture boxes, 3 picture lists, a text
box, a list box & several labels. In my list box & picture lists
there're lots of items. What I wanna do is choose an item from the list
box. But when I do that I want to show 3 pictures in my picture boxes &
show a text in my text box.

It means, imagine there's an item in my list box called " X " &
there're items in my picture lists which are also called X ( or any
other name ). When I choose the item X from the list box, I want to
show those items ( which I mentioned ) from my picture lists through
the picture boxes & also I want to show a certain text through the text
box.


Can you teach me the right kind of codes which I need in here
????



I hope you will help me with this. Thank you very much.
 
Hi,

(01)
I have created 25 different forms for various purposes.
You know with buttons, labels, picture boxes, lists & stuff like that.
Imagine there's a main form with lots & lots of
buttons which I want to connect to all the other forms. What it means
is, when I click the button called A the form called A appears and
then I click the button called B, form B appears, etc,etc.

Yes your right I want them to show. I know I can do it by
adding this code to the click event of the main form " FormA.show( )".
The matter is, when I click the button A the form A appears BUT main
form doesn't close. Can you teach me a code which does these two deeds
at the same time.

Dim A As New FormA()
A.Show()
Me.Close()
After that I want to connect all these forms like pages of a
book.You know like NEXT & PREVIOUS. It means I want to click a button
in the form A to show the Form B. But I want Form A to close at the
moment the Form B appears & then click a button from the Form B to show
the Form C & to close Form B when the Form C appears, etc, etc.
Also I need the code to go back. It's like this. I'm clicking on
the button called BACK in the form C & I get the form B ( Form B
appears). & I want form C to close, too. You see I want these both
works to happend at once.

It sounds like you are trying to create a "Wizard". Things could get complicated, but here are your best options as I see them:

1. Continue with your current architecture, but beware that things will most likely get out of control, really fast. If you want to
add more wizard-like functionality in the future your going to find it harder and harder to do such a thing using multiple Forms.
Also, the user experience will most definately suffer.
2. Create a single Form to display navigation controls and multiple UserControls, in succession, that implements some interface,
such as IWizardControl, and create a UserControl and IWizardControl implementation for each step of the Wizard. Create a
WizardController class to act as the user process component that controls the flow of the wizard and stores state information.
(This is a simple example, but its still not a trivial task.)
3. Purchase a third-party Wizard control.

The best architectural choice is #3, then #2 if you have a limited budget for your project or cannot find a third-party control that
is suitable. I would advise against #1 entirely if, in fact, you are trying to create a custom Wizard.
(03)
In my Form A there are 3 picture boxes, 3 picture lists, a text
box, a list box & several labels. In my list box & picture lists
there're lots of items. What I wanna do is choose an item from the list
box. But when I do that I want to show 3 pictures in my picture boxes &
show a text in my text box.

It means, imagine there's an item in my list box called " X " &
there're items in my picture lists which are also called X ( or any
other name ). When I choose the item X from the list box, I want to
show those items ( which I mentioned ) from my picture lists through
the picture boxes & also I want to show a certain text through the text
box.

Sounds like you want to data-bind your controls.

You can bind the properties of one control to the properties of another in the VS.NET designer. You can also bind your list
controls to data lists or objects using the designer. For example:

Bind a ListBox:

1. In the Form designer select a ListBox that you want to bind to a data source
2. View the properties window
3. Find the Data category
4. Select the drop-down arrow on the DataSource node
5. Click "Add Project Data Source..." or select an existing data source.
(If you just want to test this functionality, browse to a database and bind to one of the DataTables in the DataSet that is
generated.)
6. Select the DisplayMember node
7. Select the ValueMember node

Bind the SelectedValue of the ListBox to a TextBox:

1. In the Form designer select a TextBox that you want to bind to one of your ListBox controls
2. View the Properties window
3. Find the Data category
4. Find the DataBindings node and expand it
5. In the Text node enter the following:
listBox1 - SelectedValue
(Enter " - SelectedValue", as is, into the Text node and prepend it with the name of the ListBox.)

Now when you run the program the ListBox will be filled will data from your data source and selecting an item will display its
associated value in the bound TextBox.

I suggest that you do some research on data-binding in WinForms. There are countless numbers of articles, books, forums, websites
and newsgroups dedicated to data-binding.
 
Back
Top