Re: Need some help on forms
- From: "Dave Sexton" <dave@jwa[remove.this]online.com>
- Date: Wed, 30 Aug 2006 22:25:45 -0400
Hi,
Try Me.Hide() to hide the main form instead of closing it.
--
Dave Sexton
"harrypotter" <ruvinika86@xxxxxxxxx> wrote in message
news:1156961348.932255.203680@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Dave Sexton wrote:
Hi,
<snip>
(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<snip>
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.
--
Dave Sexton
Dear Mr.Dave,
Thank you very much for sending me recovers. I further like to
ask you about certain web sites where I can get more help.
&
I used your code : Dim A As New FormA()
A.Show()
Me.Close()
It work for the sub forms BUT didn't work for the main form ( You're
remember about my main form right ? )
When I use this code with my main form the other sub forms appears but
the main form doesn't close. The code " Me.Close() " makes the whole
project close.
I can't find another way to recover this problem. Is there a way which
can use only to close the main form ?
To get rid of this matter I erased the part " Me.close()" from the main
form.
& after I compile the project it works like this.
The main form appears. ( When I click " Next" )
The Form A appears. BUT the main form still works.
( When I click the " Next" button from the form A )
The form B appears & the form A closes.
See...The Code " Me.close()" works with the sub forms but doesn't seems
to work with the main form.
I expect that you will reply me with an answer soon or I'll be stuck
forever. So please help me.
.
- References:
- Need some help on forms
- From: harrypotter
- Re: Need some help on forms
- From: Dave Sexton
- Re: Need some help on forms
- From: harrypotter
- Re: Need some help on forms
- From: Dave Sexton
- Re: Need some help on forms
- From: harrypotter
- Need some help on forms
- Prev by Date: RE: why ever use structs vrs. classes?
- Next by Date: RE: DataMember property 'ContractID' cannot be found on the DataSo
- Previous by thread: Re: Need some help on forms
- Next by thread: Insert Date into SQL c# - Correct Format
- Index(es):
Relevant Pages
|