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?
public override void Initialize(IComponent component)
{
base.Initialize(component)
MyUserControl myControl = (MyUserControl)Component;
Messagebox.Show(myControl.
}
What I am trying to do here is to bring to front all of the added controls, but unfortunately the count shows that they are not there. In other words any control dragged unto my usercontrol do not show up at this point. This leads me to believe that the designer is just for the usercontrol itself. In addition I have tried the code that brought the textbox to the front when it is first dragged unto the control (which worked until you closed the form), but instead of putting it just into the InitializeNewComponent method of the designer I created for the textbox (child control of the usercontrol), I also put it into the initialization method thinking it would be called every time the form is created. It did not work, the text box was still behind the content in the usercontrol. So there must be something that co-ordinates the two designers and this is where I am not sure how to use your answer. You say the z-order must be saved as a property in the designer file. What designer file are you referring to? In addition how would you represent the z-order as a property. What would you do with this property to get the textbox up front. The only ways to layer controls I am familiar with is the SendToBack and MoveToFront Methods, I am not aware of any Z-order property or anything else like that.
Again, I apologize for not understanding your answer right away I am sure it must seem pretty basic to you.
Thanks again