The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

sizers for .NET

wxWidgets has a concept called "sizers" which adjust the size of a widget based on the size changes of its parent. This is all done automatically. You don't have to write code for it other than creating the sizer and attaching the child widget to it.

Is there such a thing in the .NET world or do I have to do this manually by hooking onto the OnSize event of the parent and adjusting the size of the child inside this event handler?
coder
Wednesday, December 13, 2006
 
 
Have you looked at the anchor and docking properties of controls? I don't know wxWidgets but would assume that they provide simiar functionality. You should never have to hook to the resize event or similar.

In .NET 2.0 you might also look at the System.Windows.Forms.Layout namespace as there are several new panel controls that handle different layout techniques.
dood mcdoogle
Wednesday, December 13, 2006
 
 
The Anchor property sticks your control to the edge of its parent; if you anchor opposing sides of the control (e.g. Left and Right), it shrinks and stretches when the parent's size changes.

You'll also want to check out TableLayoutPanel and FlowLayoutPanel.  With the right combination of Autosize on those controls and their child controls, you can get forms that autosize for any eventuality.  But it does take a little practice to get used to how they work.
Kyralessa Send private email
Wednesday, December 13, 2006
 
 
Just a thought: blindly adjusting the sizes of widgets is often NOT what you want. For example, when you maximize Excel, it magically maximizes the amount of cells that you can see, but it does NOT adjust the size within each cell, nor does it adjust button sizes and so on. In fact I would say that the majority of widgets in most apps you do NOT want to resize... just the ones that show the bulk of the data, which might be just a single Grid control, or whatever.
Greg Send private email
Wednesday, December 13, 2006
 
 
Sizes in wxWidgets don't work quite like that.
The widget has a fixed maximum size, it is the arrangement of the widgets in the panel that is dynamic - you basically just say that this button is underneath that button and the whole block of buttons is to the left of the grid control.
This is necessary for cross platform where the size of a control varies but it also makes layout much easier because the system does it for you. A bit like using Tex instead of DTP.

Sizers originated in TK where they were called packers which is a much better word for them.
Martin Send private email
Thursday, December 14, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz