MostafaZ4 MostafaZ4 - 1 year ago 75 Question

What is this Form layout called or how to achieve it?

What is this Form layout called in .NET and how do I achieve it?

Example of what i want to achieve

I want to know the name or the way to create a layout that windows/forms shows below previously shown ones and if there is the ability to minimize any of the opened windows as shown in the example image.

Answer Source

The layout is typically called a StackPanel.

Your image looks to be from Tibia. There is an open source version at Open Tibia (Github). You can see the code they've used to create it in stackpanel.h / stackpanel.cpp but it isn't a trivial example, there's a lot of code.

Although the child elements are referred to as 'windows' in their code, they're not truly windows such as you'd expect to see in .NET. It's just a name they've used.

If you're looking to implement it in .NET you'll have some of the basic classes available but you'll still have a lot of coding to do, and that's probably outside the scope of a stackoverflow question.

Some reading

Assuming you wanted to write it in C# (WPF), I'd start by reading up on the StackPanel class. There's a bunch of tutorials available if you search. The StackPanel

Arranges child elements into a single line that can be oriented horizontally or vertically.

An example of using the WPF StackPanel from MSDN

<StackPanel Margin="20">
    <Rectangle Fill="Red" Width="50" Height="50" Margin="5" />
    <Rectangle Fill="Blue" Width="50" Height="50" Margin="5" />
    <Rectangle Fill="Green" Width="50" Height="50" Margin="5" />
    <Rectangle Fill="Purple" Width="50" Height="50" Margin="5" />

As for the individual 'windows' (child elements), I would suggest going with UserControl or custom control to represent a window - see Control Authoring Overview. This is where most of the hard work would be. You'd need to define the layout of the content, buttons, scrollbars, etc.

You'd then stack these in the StackPanel.

For the minimizing, you could get something like the basic idea with an Expander, but you'd more likely have to write something yourself to replicate the behaviour fully.

If you're working with Windows Forms and/or VB.Net you should have access to similar basic classes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download