473,793 Members | 2,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Window Form, Panel, can't set ZOrder at run time/design time

I'm using VS 2005, .net 2.0 for a desktop application (Window Form app).

I can't set ZOrder of Panel control neither at design time by toolbar/menu
command "Bring to Front"/"Sent to Back" nor at run time by calling
BringToFront method of panel. And Panel control doesn't support SetTopLevel
method etc. I tried this while Dock=Fill and Dock=None but its not working at
all.

Please tell me how can I change Panel's ZOrder specially at run time, I have
to show different panels at different times. Is there any way to do this or I
have to set their Visible to true/false to achieve this.
Nov 20 '06 #1
12 9136
Seems to work fine for me (below)... what are you doing differently?
But yes - changing the visibility is an option, and it sounds like what you
are doing is very similar to the TabPage implementation too...

using System;
using System.Windows. Forms;
class Program
{
static void Main()
{
using (Form form = new Form()) {
for(int i = 0; i < 5; i++) {
Panel p = new Panel();
Button b = new Button();
b.Click += delegate {
p.SendToBack();
};
b.Text = "Panel " + i.ToString();
p.Dock = DockStyle.Fill;
p.Controls.Add( b);
form.Controls.A dd(p);
}
Application.Run (form);
}

}
}
Nov 20 '06 #2
Marc,
The only thing I'm doing different is you are creating it at run and I added
it at design time to the form and that is not any different in .net because
designer also adds the same instantiation code. So, the only difference is
your controls creation code is in Main() method and mine is in Form's
constructor.

I checked it again, its still not working neither at design time, nor at run
time even I checked the SendToBack method of panel at run time but its not
working. I can do it with Visible but I have 4-5 panels up and down and I
have to take of visibility of all panels.

Have you executed your code in .net 2.0?

regards,
Adil

"Marc Gravell" wrote:
Seems to work fine for me (below)... what are you doing differently?
But yes - changing the visibility is an option, and it sounds like what you
are doing is very similar to the TabPage implementation too...

using System;
using System.Windows. Forms;
class Program
{
static void Main()
{
using (Form form = new Form()) {
for(int i = 0; i < 5; i++) {
Panel p = new Panel();
Button b = new Button();
b.Click += delegate {
p.SendToBack();
};
b.Text = "Panel " + i.ToString();
p.Dock = DockStyle.Fill;
p.Controls.Add( b);
form.Controls.A dd(p);
}
Application.Run (form);
}

}
}
Nov 20 '06 #3
Marc,
Another thing different I'm doing, I forget to tell you is I put my panel
controls inside the SplitContainer control's panel.

regards,
Adil

"Marc Gravell" wrote:
Seems to work fine for me (below)... what are you doing differently?
But yes - changing the visibility is an option, and it sounds like what you
are doing is very similar to the TabPage implementation too...

using System;
using System.Windows. Forms;
class Program
{
static void Main()
{
using (Form form = new Form()) {
for(int i = 0; i < 5; i++) {
Panel p = new Panel();
Button b = new Button();
b.Click += delegate {
p.SendToBack();
};
b.Text = "Panel " + i.ToString();
p.Dock = DockStyle.Fill;
p.Controls.Add( b);
form.Controls.A dd(p);
}
Application.Run (form);
}

}
}
Nov 20 '06 #4
Marc,
I tried placing several panels in same project on another form and their
BringToFront/SendToBack working both at design time and runtime. I think the
SplitterContain er is the real culprit and prevents panels to work properly.

Have you any solution for the panels inside SplitterContain er to work or
I'll have to use Visible property.

regards,
Adil

"Marc Gravell" wrote:
Seems to work fine for me (below)... what are you doing differently?
But yes - changing the visibility is an option, and it sounds like what you
are doing is very similar to the TabPage implementation too...

using System;
using System.Windows. Forms;
class Program
{
static void Main()
{
using (Form form = new Form()) {
for(int i = 0; i < 5; i++) {
Panel p = new Panel();
Button b = new Button();
b.Click += delegate {
p.SendToBack();
};
b.Text = "Panel " + i.ToString();
p.Dock = DockStyle.Fill;
p.Controls.Add( b);
form.Controls.A dd(p);
}
Application.Run (form);
}

}
}
Nov 20 '06 #5
Have you executed your code in .net 2.0?
Yes

Marc
Nov 20 '06 #6
Still works fine for me... Have you any code that demonstrates this?

using System;
using System.Windows. Forms;
using System.Drawing;
class Program
{
static void Main()
{
using (Form form = new Form())
using (SplitContainer sc = new SplitContainer( ))
{
sc.Panel1.BackC olor = Color.Red;
sc.Panel2.BackC olor = Color.Blue;
AddPanels(sc.Pa nel1);
AddPanels(sc.Pa nel2);
sc.Dock = DockStyle.Fill;
form.Controls.A dd(sc);
Application.Run (form);
}

}

private static void AddPanels(Split terPanel panel)
{
for (int i = 0; i < 5; i++)
{
Panel p = new Panel();
Button b = new Button();
b.Location = new System.Drawing. Point(10 * i, 10 * i);
b.Click += delegate
{
p.SendToBack();
};
b.Text = "Panel " + i.ToString();
p.Dock = DockStyle.Fill;
p.Controls.Add( b);
panel.Controls. Add(p);
}
}
}

Marc
Nov 20 '06 #7
Adil Akram wrote:
Marc,
I tried placing several panels in same project on another form and their
BringToFront/SendToBack working both at design time and runtime. I think the
SplitterContain er is the real culprit and prevents panels to work properly.

Have you any solution for the panels inside SplitterContain er to work or
I'll have to use Visible property.
I gather you are trying to have one or more panels inside a
SplitterContain er and then selectively show and hide them?

Rather than using panels, use UserControls. You can design them
separately and show them inside the panels of the SplitterContain er.

You can also do this using forms instead of UserControls.

Chris

Nov 20 '06 #8
Marc,
Thank you very much for your follow up. I again missed to mention that I'm
using a SplitterContain er inside another SplitterContain er, first one
(Parent) has vertical orientation and 2nd (Child) has horizontal orientation.
I just like to mention if it may help to find some clue.

But even with this addition to your code, its still working properly and its
annoying me so much that why it is not working for me not even at design
time. My project is currently not so big, it has a single form only and I
check it out and find nothing different I'm doing in it.

Here's your coding with addition of another child SplitterContain er and its
working.

using System;
using System.Windows. Forms;
using System.Drawing;
class Program
{
static void Main()
{
using (Form form = new Form())
using (SplitContainer sc = new SplitContainer( ))
{
SplitContainer scl = new SplitContainer( );
scl.Orientation = Orientation.Hor izontal;

scl.Panel1.Back Color = Color.Red;
scl.Panel2.Back Color = Color.Blue;
AddPanels(scl.P anel1);
AddPanels(scl.P anel2);
sc.Dock = DockStyle.Fill;
scl.Dock = DockStyle.Fill;
sc.Panel1.Contr ols.Add(scl);
form.Controls.A dd(sc);
Application.Run (form);
}

}

private static void AddPanels(Split terPanel panel)
{
for (int i = 0; i < 5; i++)
{
Panel p = new Panel();
Button b = new Button();
b.Location = new System.Drawing. Point(10 * i, 10 * i);
b.Click += delegate
{
p.SendToBack();
};
b.Text = "Panel " + i.ToString();
p.Dock = DockStyle.Fill;
p.Controls.Add( b);
panel.Controls. Add(p);
}
}
}
regards,
Adil

"Chris Dunaway" wrote:
Adil Akram wrote:
Marc,
I tried placing several panels in same project on another form and their
BringToFront/SendToBack working both at design time and runtime. I think the
SplitterContain er is the real culprit and prevents panels to work properly.

Have you any solution for the panels inside SplitterContain er to work or
I'll have to use Visible property.

I gather you are trying to have one or more panels inside a
SplitterContain er and then selectively show and hide them?

Rather than using panels, use UserControls. You can design them
separately and show them inside the panels of the SplitterContain er.

You can also do this using forms instead of UserControls.

Chris

Nov 21 '06 #9
Chris,
Thank you for your assistance and suggesting alternatives.

I have another alternate solution to use the Visible property of Panels to
show hide but it requires to do more management/coding to set visible false
for one and setting true for other.

I would just like to know that is there any known bug/design flaw in panels
ZOrder as in my case its not working not even at design time or is there
something I'm doing wrong?

regards,
Adil


"Chris Dunaway" wrote:
Adil Akram wrote:
Marc,
I tried placing several panels in same project on another form and their
BringToFront/SendToBack working both at design time and runtime. I think the
SplitterContain er is the real culprit and prevents panels to work properly.

Have you any solution for the panels inside SplitterContain er to work or
I'll have to use Visible property.

I gather you are trying to have one or more panels inside a
SplitterContain er and then selectively show and hide them?

Rather than using panels, use UserControls. You can design them
separately and show them inside the panels of the SplitterContain er.

You can also do this using forms instead of UserControls.

Chris

Nov 21 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4170
by: Yang Li Ke | last post by:
Hi guys, let's say I want to load a window behind the main window. how do i do it? because right now everytime i do it the main window gets behind and the new window get the focus. Thank you.
2
3009
by: rawCoder | last post by:
Hi I am having this InvalidOperationException with message Cannot call Invoke or InvokeAsync on a control until the window handle has been created This is raised when i try to invoke a method with arguments I need to do this as the method is being called Asynchronously from elsewhere using delegate's BeginInvoke method. The form is well created/initialized yet the messages states otherwise.
1
11589
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all out). Therefore, here goes my simple "web dialog box with parent event handler fireing" solution. ...
37
2090
by: Geoff Jones | last post by:
Hi Suppose I have two forms: Form1 and Form2. I create and show an instance of Form2 in the code of Form1 e.g. Dim myForm2 = New Form2 myForm2.Show() How do I tell myForm2 that Form1 is its parent? That is, when I look at either "Parent" or "ParentForm" in Form2, they both show "Nothing".
9
4633
by: Quina | last post by:
Hi. Is there someone that can tell me how can I have multiple screens on the the same form, displaying only on at the time? Thank you all for any replys. João Carias
0
882
by: Larry Charlton | last post by:
Is there a way to make a Panel (or other control that can contain child controls) so that it will size correctly at design time (based on CSS)? Panel seems to be doing something weird at design time. I have a CSS with a class .test { width: 40em } for example. If I drop a Panel on the page, Clear the Width, Height and set CssClass to test, and put styleSheetTheme in, the rendered size of the panel doesn't change at design time (works...
4
16268
by: Mikus Sleiners | last post by:
I can't seem to add new controls to form that is inherited from another form. I have BaseForm wich have table layout on it 2 panelsm and some buttons. Now i create InheritedForm : BaseForm and want to add some new controls and add them to pannels but i can't drag and drop them ... designer does not allow me. Why is that ? Panels and table layout modifiers is set to public.
4
4367
by: iKiLL | last post by:
Hi All I am Developing in C# with VS2005. I am Developing a Windows Mobile Forms Application with the CF2 My problem is that when the Input panel is displayed my screen does not
2
596
by: Jonathan Boivin | last post by:
Hi people, Let me introduce to how I get this error. I have a form which load all my bills representation depending upon filters which each bill is a usercontrol of my own having some textboxes containing bill's datas. (I already replaced the labels by painting the text instead.) When I click on my filter button, it clears the current usercontrol bills and load the new ones upon the current chosen filters. The bug happens when
0
9671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9035
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.