How to create a "split screen" layout

Posted by ChUIMonster on 15-Feb-2009 09:28

I'm not sure how to describe what I'm trying to do so please bear with me. And feel free to offer better terms for what it is that I'm trying to do.

I have a window with an explorer bar on the left and a "data area" on the right. Within the data area I'd like to have a layout that looks something like this:

--





--


Frame A would contain a dozen or so data fields in the usual manner.

Frames B and C would be UltraGrids showing the rows of temp tables.

I would like Frames B and C to fill the bottom left and bottom right respectively and to resize when the container resizes. Frame A should fill the top but shouldn't resize -- it should just fill whatever space it has with the appropriate background color and layout its fields in a static fashion.

I can make most of this happen manually with an UltraTabbedMDI manager by dragging the tabs around. But I'm trying to make it so that the user does not have to do that -- it seems silly to not be able to automatically set up the screen the way it will always be wanted. I don't really need the top bit to be a tab but I can live with that if I must.

I'm probably missing some obvious and easy way to do this Any ideas?

All Replies

Posted by rbf on 15-Feb-2009 09:59

Are you aware of the Anchor property?

Posted by ChUIMonster on 15-Feb-2009 10:07

I see it.

But I don't have a vision of how I would apply it.

Posted by Admin on 15-Feb-2009 10:08

Have you tried two nested SplitContainer (a Microsoft Control)? The thing that comes closest to a Frame in the ABL UI is a Panel. A SplitContainer splits it's space into two Panels.

So you could split the space into Panel A and Panel D and then Panel D into Panel B and Panel C.

Each SplitContainer has properties that allow you to control what happens during resizing (FixedPanel) or if the user is allowed to move the splitter bar.

The TableLayoutPanel (also Microsoft) might be another option. I don't recall, if it's possible to join two cells. But that also offers you space for Panels (having that said, you need to add Panel manually to each cell).

I believe the SplitContainer is on the Toolbox by Default and the TableLayoutPanel needs to be added from the GAC (System.Windows.Forms.TableLayoutPlanel).

Posted by ChUIMonster on 15-Feb-2009 10:11

"Dock" seems more appropriate but I'm having difficulty figuring out what it is that I want to be docking and where.

I think I'm confused about the hierarchy of controls needed to provide the structure that I want.

Posted by ChUIMonster on 15-Feb-2009 10:13

Ah! That looks promising.

Thanks!

Posted by rbf on 15-Feb-2009 10:16

I see it.

But I don't have a vision of how I would apply it.

Well first you create the three panels with the splitterpanel as Mike described and then you anchor your objects on those panels to control how they behave when resized.

For example, you would anchor the grids on all four sides because you want them to grow upon resizing but you would not do that for the 'viewer'.

Posted by rbf on 15-Feb-2009 10:18

"Dock" seems more appropriate but I'm having

difficulty figuring out what it is that I want to be

docking and where.

Dock and Anchor are mutually exclusive. Both could be used in this example, but you need to play around with both to appreciate the differences. For example, if you don't mind the grids touching each other you could use dock, if you want to preserve fixed space around them you would anchor.

Posted by rbf on 15-Feb-2009 10:24

The TableLayoutPanel (also Microsoft) might be another option.

Mike I don't find that control on my system. I do however find 'Microsoft.SnapIns.TrustedPlatformModule.EnhancedTableLayoutPanel' and

'Microsoft.SnapIns.TrustedPlatformModule.MirroredTableLayoutPanel'

Are these the ones you mean? Is it safe to use those since they are not in the System.Windows.Forms namespace? What would that mean for deployment?

Posted by ChUIMonster on 15-Feb-2009 10:25

Ok. That makes sense. I think I see where I need to go now!

Posted by Admin on 15-Feb-2009 10:43

I prefer Dock when there is only one Control in the Container (Form, UserControl, Panel, ...). You still can set the borders using the Margin property or in the case of the SplitContainer by the SplitterWidth.

Posted by Admin on 15-Feb-2009 10:44

I was talking about this control:

http://msdn.microsoft.com/en-us/library/system.windows.forms.tablelayoutpanel.aspx

It's part of the Windows.Forms namepace and assembly. If you don't see it - it's probably part of your toolbox.

Posted by rbf on 15-Feb-2009 11:43

It's part of the Windows.Forms namepace and assembly.

If you don't see it - it's probably part of your toolbox.

That's it. It was already in my toolbox

Posted by ChUIMonster on 15-Feb-2009 15:52

Ok, I'm almost there.

I've got the layout the way that I want it.

There is, however, a wrinkle. There's always a wrinkle... But this wrinkle is putting dents in my head so it's time to ask for help

I'm trying to dynamically add controls to the top panel. I can do it easily enough statically. For instance I can drag a button over there and drop it in place and some nice code will get generated that adds it with something like this:

So far so good.

I just happen to have a method that I've been using quite successfully with my other forms for dynamically adding fields. That method has a signature something like this:

Which creates a new control called xLabel and then does various initialization stuff and then finally adds it to the container with:

But when I try to invoke it like so:

I get a type mismatch error. It seems to me that a SplitterPanel is some sort of a ContainerControl or ControlCollection and that there ought to be some common ground in there but I'm at a loss to figure out what it is. I keep getting lost chasing around the relationships in the class browser.

Any hints?

I'm puzzled. Any ideas?

Posted by rbf on 15-Feb-2009 15:57

Have you tried:

pobj as ScrollableControl

?

Posted by Admin on 15-Feb-2009 15:59

Try Control. The Controls collection is a member of Control.

Posted by ChUIMonster on 16-Feb-2009 10:33

Thanks guys! Everything is working now

This thread is closed