troubleshooting Question

Z-Order problem with usercontrols

Avatar of exptech
exptechFlag for United States of America asked on
.NET ProgrammingC#Editors IDEs
5 Comments1 Solution908 ViewsLast Modified:
Ok, here is my problem. It would seem like there is a simple solution but so far it has eluded me. I have a usercontrol which consists of a Developers Express (using their components) group box which is docked to all sides so it always fills the usercontrol. Inside of the groupbox there are a few buttons and a DE memoedit control docked to the bottom of the groupbox. I don't think the contents of the group box make a difference anyway. I am able to drag the control onto a form with no trouble, but I wanted to be able to place other controls inside the usercontrol at design time so I added the following above the usercontrol class definition:

[Designer(typeof(ParentControlDesigner))]

This now allowed me to place other controls into my usercontrol at design time. When I move the usercontrol the controls move with it and they are clearly inside the usercontrol when you look at the document outline window, but here is the problem. When you place any control on the usercontrol it's z-order puts it behind the contents already in the usercontrol (the DE Group Box). If you select it in the document outline and then click on a handle and select move to front, the control places itself on top of everything else and all is well. That is until you save and reopen the form. When you reopen the form all of the controls you placed are once again behind the usercontrol contents. You would think when you saved the form the z-order would be saved but it does not work. The problem is there are going to be many of these usercontrols with a good deal of controls placed on top. Going from control to control and correcting them is not an option. I have even tried implementing a custom designer for a textbox control that I modified and is now a usercontrol. Here is the code:

            public override void InitializeNewComponent(System.Collections.IDictionary defaultValues)
            {
                base.InitializeNewComponent(defaultValues);

                ILTextEdit ilTextEdit = (ILTextEdit) Component;

                ilTextEdit.BringToFront();
            }

Hopefully this is the right way to access the component itself, I have very little experience with designers or the programming the visual studio IDE, though I have a decent amount of experience with C# applications. In any event when I drag this component unto the usercontrol now it is the top most control and it looks like the
problem is solved. Again, that is until you save the form and reopen it, just to find out the control is once again hidden.

Anyone have any idea how to correct this?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros