Click here to Skip to main content
15,885,869 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
I have several controls that follow a similar pattern and require the same resizing logic. I am using the XPPanel controls from this Code Project Full-featured XP Style Collapsible Panel

So my approach is to create a derived control from the XPPanel control that has several containers and a DataGridView control. The Hierarchy of the derived control will be:

1 XPPanel
2 Collapsible Group Box - Search Criteria
2 Group Box - Results
3 DataGridView
3 Panel for buttons
3 Collapsible Group Box - Details for selected grid control

The sizing algorithm is to adjust the size of the datagridview based on the size of the XPPanel (Driven by monitor resolution and user sizing) and the other group boxes and panel. The goal is to balance the amount of rows visible against the amount of details that can be seen without having to scroll the window.

I want this to be a control that I can derive each of the specific controls from so I can have this class handle the resizing logic and setting the scrolling min sizes.

So my idea was to create the derived class for each of the final controls and then fill the group boxes and the Panel with the appropriate controls for that specific control.

I did something similar when I created a Dialog Control that was derived from a form control and contained the OK and Cancel button. Then I derived the actual dialog boxes from this control.

The problem I am running into is when I try to create a control derived from XPPanel the designer screen does not let me place the group boxes, panel and datagridview so they display as they would at run time. Instead I just get an icon and text that represent the control.

Is what I am trying to do possible?

Can someone suggest a better way to resolve the problem?

Should I be using Layout Controls?

Some more Details:

I am using VS 2005
Posted
Comments
BillWoodruff 5-Jan-13 17:13pm    
As I understand it, you can't get the designer view you want, but, at run-time, do your derived Controls appear where you want them to be ?

I doubt you will get an answer to this question, since it involves going back into the code of a CP 2004 article and trying to figure out how it works, and using VS 2005.

But, I hope you do get an answer !

Have you searched CP for more recent articles on "collapsible" Container Controls ?

good luck, Bill
Jibesh 5-Jan-13 20:14pm    
Have you heard about Inherited User Controls in C#, partial of your requirement can be met by this.
Bill Langlais 5-Jan-13 22:40pm    
Bill, Thanks for taking the time to respond. I believe what I am looking for is Visual Inheritance. I believe this is the ability of a control to inherit from another control and have it be displayed in the designer.

The sizing part is the ultimate goal but the problem is with the solution I am trying.

I want to be able to create a user control that contains some containers and then be able to add controls to those containers. What I am going to try next is just a simple case with a user control that has two panels. Then derive another control from the user control and see if I can add to the two panels.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900