Problem with panels
-
Hi there all ! In my windows form application i add a tollstrip and 4 buttons on it. I also add 4 panels on form on Dock property: Fill. Mayby it's lame question but I want to modify some of this 4 panels and i go in properties and check for example Panel2 - the list of properties of this control is available but on form i still see a panel1, how i can see my panel2, or 3? I just want to add to this panels some buttons etc... best regards
-
Hi there all ! In my windows form application i add a tollstrip and 4 buttons on it. I also add 4 panels on form on Dock property: Fill. Mayby it's lame question but I want to modify some of this 4 panels and i go in properties and check for example Panel2 - the list of properties of this control is available but on form i still see a panel1, how i can see my panel2, or 3? I just want to add to this panels some buttons etc... best regards
If you add several Controls to a Form and give them all DockStyle.Fill, they will overlap and only one at a time will be visible. What you can do is this: - in Visual Designer click/select one of the Controls or the Form itself; - now open the properties pane, it will show the properties for that control; - on the top it also has a ComboBox listing all the Controls of the Form; select the one you want, I expect that suffices to make it visible. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
Hi there all ! In my windows form application i add a tollstrip and 4 buttons on it. I also add 4 panels on form on Dock property: Fill. Mayby it's lame question but I want to modify some of this 4 panels and i go in properties and check for example Panel2 - the list of properties of this control is available but on form i still see a panel1, how i can see my panel2, or 3? I just want to add to this panels some buttons etc... best regards
Nope: it doesn't work like that. When you select "Dock...Fill" the panel covers the entire client area, and will re-size itself to make sure it always does. If you have multiple controls that are all set to Fill, then tehy are all teh same size, and stacked behind each other. The only way to see them at run time is to make three of them
Visible=False
and one of themVisible=True
At Design time, they are also stacked up, only you can't make them invisible. The only way I know to select a specific panel is to use the drop down list at the top of the Properties window. Even that won't let you select panel1 and drop controls on it if panel 2 is on top of it. To do that, you will have to select a panel, use the "send to back" button, select a different panel, "send to back" and repeat until you have the panel you wanted. An easier (and nicer for the user) approach might be to use a TabControl instead, and put each of the panels on separate tabs.Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
-
If you add several Controls to a Form and give them all DockStyle.Fill, they will overlap and only one at a time will be visible. What you can do is this: - in Visual Designer click/select one of the Controls or the Form itself; - now open the properties pane, it will show the properties for that control; - on the top it also has a ComboBox listing all the Controls of the Form; select the one you want, I expect that suffices to make it visible. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
Luc Pattyn wrote:
I expect that suffices to make it visible.
Unfortunately not. You have to play silly beggars with the "Bring to front" / "Send to back" buttons to do anything useful (like drop controls on them). Certainly this is the case in VS2008 - I haven't tried it in VS2010. :laugh:
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
-
Nope: it doesn't work like that. When you select "Dock...Fill" the panel covers the entire client area, and will re-size itself to make sure it always does. If you have multiple controls that are all set to Fill, then tehy are all teh same size, and stacked behind each other. The only way to see them at run time is to make three of them
Visible=False
and one of themVisible=True
At Design time, they are also stacked up, only you can't make them invisible. The only way I know to select a specific panel is to use the drop down list at the top of the Properties window. Even that won't let you select panel1 and drop controls on it if panel 2 is on top of it. To do that, you will have to select a panel, use the "send to back" button, select a different panel, "send to back" and repeat until you have the panel you wanted. An easier (and nicer for the user) approach might be to use a TabControl instead, and put each of the panels on separate tabs.Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
Thanks for help i did a similar but i take 3 panels and set to dock: fill and I made sure that's not any one panel is child of the other panel... So i set all panels are on Form1. Then if i want to modify some panel i used Format -> Order -> Bring to front then i have access to a panel which i want to modify... I also type those 3 panels on
visible = false
and
private void toolStripSplitButton2\_ButtonClick(object sender, EventArgs e) { panel2.Visible = false; panel3.Visible = false; panel1.Visible = true; } private void toolStripButton1\_Click(object sender, EventArgs e) { panel2.Visible = true; panel1.Visible = false; panel3.Visible = false; } private void toolStripButton2\_Click(object sender, EventArgs e) { panel3.Visible = true; panel1.Visible = false; panel2.Visible = false; }
so it's that good in code? Or should i some change?
-
Thanks for help i did a similar but i take 3 panels and set to dock: fill and I made sure that's not any one panel is child of the other panel... So i set all panels are on Form1. Then if i want to modify some panel i used Format -> Order -> Bring to front then i have access to a panel which i want to modify... I also type those 3 panels on
visible = false
and
private void toolStripSplitButton2\_ButtonClick(object sender, EventArgs e) { panel2.Visible = false; panel3.Visible = false; panel1.Visible = true; } private void toolStripButton1\_Click(object sender, EventArgs e) { panel2.Visible = true; panel1.Visible = false; panel3.Visible = false; } private void toolStripButton2\_Click(object sender, EventArgs e) { panel3.Visible = true; panel1.Visible = false; panel2.Visible = false; }
so it's that good in code? Or should i some change?
It's clear enough! I would be tempted to have a generic routine which sets them all invisible and then set only the one I want visible though:
private void toolStripSplitButton2\_ButtonClick(object sender, EventArgs e) { SetVisible(panel1); } private void toolStripButton1\_Click(object sender, EventArgs e) { SetVisible(panel2); } private void toolStripButton2\_Click(object sender, EventArgs e) { SetVisible(panel3); } private void SetVisible(Panel p) { panel1.Visible = false; panel2.Visible = false; panel3.Visible = false; p.Visible = true; }
For just three panels, I would be happy enough with that: to go any higher, I would use a loop instead:
private void SetVisible(Panel p) { foreach (Control c in Controls) { Panel pan = c as Panel; if (pan != null) { pan.Visible = false; } } p.Visible = true; }
Oh, and I would get rid off your names! Don't use "panel1", "panel2", "tool_stripButton2" etc.: use names that describe what they contain. "panColors" and "panFonts", "tsbSelectColors" and "tsbSelectFonts" help the readability of your code a lot, and that makes it easier to debug and work with.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
-
Luc Pattyn wrote:
I expect that suffices to make it visible.
Unfortunately not. You have to play silly beggars with the "Bring to front" / "Send to back" buttons to do anything useful (like drop controls on them). Certainly this is the case in VS2008 - I haven't tried it in VS2010. :laugh:
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
Tried it in VS2008, and you're right. :thumbsup:
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
-
It's clear enough! I would be tempted to have a generic routine which sets them all invisible and then set only the one I want visible though:
private void toolStripSplitButton2\_ButtonClick(object sender, EventArgs e) { SetVisible(panel1); } private void toolStripButton1\_Click(object sender, EventArgs e) { SetVisible(panel2); } private void toolStripButton2\_Click(object sender, EventArgs e) { SetVisible(panel3); } private void SetVisible(Panel p) { panel1.Visible = false; panel2.Visible = false; panel3.Visible = false; p.Visible = true; }
For just three panels, I would be happy enough with that: to go any higher, I would use a loop instead:
private void SetVisible(Panel p) { foreach (Control c in Controls) { Panel pan = c as Panel; if (pan != null) { pan.Visible = false; } } p.Visible = true; }
Oh, and I would get rid off your names! Don't use "panel1", "panel2", "tool_stripButton2" etc.: use names that describe what they contain. "panColors" and "panFonts", "tsbSelectColors" and "tsbSelectFonts" help the readability of your code a lot, and that makes it easier to debug and work with.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
ok i rename it all and put thise code :
private void toolStripSplitButton2_ButtonClick(object sender, EventArgs e)
{
SetVisible(panel1);
}private void toolStripButton1\_Click(object sender, EventArgs e) { SetVisible(panel2); } private void toolStripButton2\_Click(object sender, EventArgs e) { SetVisible(panel3); } private void SetVisible(Panel p) { foreach (Control c in Controls) { Panel pan = c as Panel; if (pan != null) { pan.Visible = false; } } p.Visible = true; }
it's more beauty of code... than set all false/true without the intended purpose if the panels will... :) P.S It's really uncomfortable to switch between all panels "bring to front" :) thx for help !!
-
ok i rename it all and put thise code :
private void toolStripSplitButton2_ButtonClick(object sender, EventArgs e)
{
SetVisible(panel1);
}private void toolStripButton1\_Click(object sender, EventArgs e) { SetVisible(panel2); } private void toolStripButton2\_Click(object sender, EventArgs e) { SetVisible(panel3); } private void SetVisible(Panel p) { foreach (Control c in Controls) { Panel pan = c as Panel; if (pan != null) { pan.Visible = false; } } p.Visible = true; }
it's more beauty of code... than set all false/true without the intended purpose if the panels will... :) P.S It's really uncomfortable to switch between all panels "bring to front" :) thx for help !!
nighttrain1 wrote:
P.S It's really uncomfortable to switch between all panels "bring to front
Ain't that the truth! :laugh: That's partly why I prefer the TabControl approach.
nighttrain1 wrote:
thx for help
You're welcome!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
-
nighttrain1 wrote:
P.S It's really uncomfortable to switch between all panels "bring to front
Ain't that the truth! :laugh: That's partly why I prefer the TabControl approach.
nighttrain1 wrote:
thx for help
You're welcome!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
"hehe" :D thx again
-
Hi there all ! In my windows form application i add a tollstrip and 4 buttons on it. I also add 4 panels on form on Dock property: Fill. Mayby it's lame question but I want to modify some of this 4 panels and i go in properties and check for example Panel2 - the list of properties of this control is available but on form i still see a panel1, how i can see my panel2, or 3? I just want to add to this panels some buttons etc... best regards
If you want to add several controls(panels in your case) to the same form and Dock them all as Fill, below is the best solution: - Add Custom user controls to your Project, each of them containing one of the panels. - Add these controls to your form and dock them as Fill. Now if you want to edit one of the panels, simply edit the custom user control you created ;)