newbie: 1 form w/ 3 panels, cycle through ....

E

Esmail Bonakarian

Greetings all,

I am trying to display several screens/views of the interface to a
user by using multiple panels within the same form by making them
visible/bringing them to the front as needed. This instead of popping
up several different forms. I am having problems with this.

Here's the basic setup:

Form F - contains 3 panels
(this is also the order in which I want to display them):

Panel pnl_IS; // displays an instruction screen
// it has a RichTextBox and an OK
// button on it. Their parents have
// been set to pnl_IS

Panel pnl_PAUSE; // displays a simple label and
// also has an OK button on it.
// Their parents have been set
// to pnl_PAUSE

Panel pnl_nutriLabel // similar to pnl_Pause, at
// this point only has an OK
// button on it. Parent of button
// set to pnl_nutriLabel
// eventually, I will want to display
// some graphics on a part of this panel,
// probably by creating another panel within
// this ..

I am also assuming that if I make another control's parent a panel,
then the visibility property will carry over to the child control? Ie
if I make the parent (panel) visible, the child (button) will also
become visible. Correct?

from my constructor:

pnl_IS.BringToFront();

pnl_PAUSE.SendToBack();
pnl_PAUSE.Visible = false;

pnl_nutriLabel.SendToBack();
pnl_nutriLabel.Visible = false;

My three event handlers, they are supposed to help me display
the next panel as I click on OK.

private void btnOk_Click(object sender, System.EventArgs e)
{
pnl_IS.SendToBack();
pnl_IS.Visible = false;
pnl_PAUSE.Visible = true;
}

private void btnContinueOK_Click(object sender, System.EventArgs e)
{
pnl_PAUSE.SendToBack();
pnl_PAUSE.Visible = false;

pnl_nutriLabel.BringToFront();
pnl_nutriLabel.Visible = true; <------ doesn't change
}

private void btn_nutriLabel_Ok_Click(object sender, System.EventArgs e)
{
//pnl_nutriLabel.SendToBack();
this.Close();
}

The first two panels work (ie come up/become visible) as expected,
however, my nutriLabel panel never shows its OK button and in the
debugger its Visible property doesn't change. I'm at a loss.

I suspect this is something really simple I am missing.

Any suggestions? I'm new to programming with Win Forms, though
not to programming ;-)

Thanks!
Esmail


(As an aside, is the way of multiple panels w/i 1 form to display
multiple views/screens an accepted way of implementing this? Or is
there another, perhaps better way?)

(Aside #2 - when I'm in the designer with this form, I am having a
hard time to cycle through the panels with the mouse controls to bring
them to the front for modification etc, esp since the 3 panels have
the same size/position w/i the their parent form. Is there an easier
way to do this? Also, if a control has a panel as its parent - set
programatically (I don't know of another way to do this), should they
also become visible - it doesn't appear so)
 
E

Esmail Bonakarian

Hiya!

Got it .. my 3rd panel, since it was a copy/paste of the 2nd panel
had it, rather than my Form as it's parent. I fixed this by explicitly
saying


pnl_IS.Parent = this;
pnl_PAUSE.Parent = this;
pnl_nutriLabel.Parent = this;

Still curious if this approach to showing mutliple screens/views
to the user is a good one, or if there there is a better way.

If anyone has comments on the three things below I'd be happy to
hear them. thanks!
I am also assuming that if I make another control's parent a panel,
then the visibility property will carry over to the child control? Ie
if I make the parent (panel) visible, the child (button) will also
become visible. Correct?


(As an aside, is the way of multiple panels w/i 1 form to display
multiple views/screens an accepted way of implementing this? Or is
there another, perhaps better way?)

(Aside #2 - when I'm in the designer with this form, I am having a
hard time to cycle through the panels with the mouse controls to bring
them to the front for modification etc, esp since the 3 panels have
the same size/position w/i the their parent form. Is there an easier
way to do this? Also, if a control has a panel as its parent - set
programatically (I don't know of another way to do this), should they
also become visible - it doesn't appear so)

Cheers,
Esmail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top