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)
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)