views:

743

answers:

5

We have developed a software. In this software we are show and hiding a few controls on various input screens depending on various situations.

When we hid a control what happens is that the space occupied by that control is left as it is and layout looks very bad at times esp. in screens that have larger numbers of controls. Our client does not like this and has asked us to do something about this.

My question: Is there some way by which we can create Fluid Layouts so that when a control is hidden the rest of the controls automatically adjusts themselves to fill the empty space left by the control hidden and when the control is show they should automatically make way for the control and adjust themselves accordingly.

I know we can achieve this by coding but that will require a lot of code in each screen for adjusting the layout. I am looking something which will reduce coding in each screen as there are 80+ screens.

Please suggest some way which is less error pron and can get rid of unnecessary coding in each input screen.

+9  A: 

I think your best option is to use a component that handles the layout of your vcl controls on your form in runtime (depending on the conditions that you define). I recommend you try the Devexpress ExpressLayout Control

you can find two great demo videos here

alt text

You can check these features

Auto-Management - Control groups and individual control elements are automatically managed by the Layout Control. You never worry about pixel-by-pixel positioning.

Form auto-sizing - The form can be automatically resized to fit its contents best.

Bye.

RRUZ
Will this component allow us to have our own screen layout will is restrict us in creating our layouts?
Yogi Yang 007
After going through ExpressLayout details it seems to be some sort of interface for allowing end users to customize the layout as per their needs. This is not what I need. The end users will not be able to modify anything. The layout should automatically adjust itself when any control is hidden or shown.
Yogi Yang 007
@Yogi Yang 007, this component allow to the end users to customize the layout, that is correct, but this is not the only feature of this control, nor the reason for what I recommend it.
RRUZ
+1 for (new) LayoutControl! You can also control its behaviour by code. If you hide a control, other controls will fill up the space. All our formas are always perfectly aligned by using this control.
birger
+1 for DevExpress' LayoutControl. I don't think there's anything you want it to do that cannot be done.
yozey
A: 

What kind of controls are you dynamically hiding, and what do you mean with auto fill space?

I do not know if it is as this simple: place controls on panels, and use align alTop/alClient/alBottom. When you hide a panel, all other panels will move automatically up. One problem though: if you want to show a panel again, the order of panels can sometimes be screwed up... Can be fixed by manually setting .Top property, or "hide" by setting .Height := 1;

André
This is what flowpanel handles better than a regular panel with topaligned childs. ;-)
Vegar
Yes you're true, but flowpanel is D2007+? We do not know which Delphi version he is using...
André
We are using Delphi 6 and 2006. Not upgraded to any other versions and do not plan to do so in near future.
Yogi Yang 007
+3  A: 

Now, I'm not sure how complex layout you have, but I guess you can use TFlowPanel and/or TGridPanel for this. Flowpanel has a nice handling of components that change visiblity. I'm not sure how well gridpanel handles the same...

Vegar
The software is for Doctors. It contains a lot of input controls some of screens are very complicated where controls are shown and hidden based on various selections at the top of the screen as well as user rights.
Yogi Yang 007
I would go for the flow panel. Try to group related components in panels, or frames, and place this panel in a flow panel together with the other panels. When you now hide one panel, other panel will use the available space. GridPanel may be to limited for this use.
Vegar
Thanks for your hint. I will look into this.
Yogi Yang 007
A: 

What I would do with a complex layout is actually split it up into several tabs. This has two advantages. It simplifies the form layout, and allows you to show and hide whole tabs depending on choices made in other tabs.

Steve
A: 

Raize Components have a TRzFlowPanel UI component. Does exactly what you're after.

Use TRzFlowPanel to put an empty flow panel on a form. The major difference between a traditional panel and a flow panel is the way in which controls are placed. With a traditional panel, you place a control (such as a button) in a specific location. You can freely move that control to any location within the panel using the mouse. In a flow panel, each control is placed in a specific location, regardless of where you place it with the mouse. The automatic location is controlled by the FlowStyle property. For example, using the default FlowStyle property of LeftRightTopBottom, the first control you add to the flow panel snaps to the top left corner. The second control that you add snaps next to the first control, and so on.

Gerard