Can you give us an idea why and how you want to use it.
Before you wrote this message I had not noticed this property ever
Cor
"TC" wrote in message
I'm trying to layout controls on a form, and I'm finding it very
difficult. Net offers several properties and methods designed to help
with layout, but they are poorly documented and I can't figure out how
to use them.
In order to arrange the controls the way I want them, I need to know
the size each control needs to display its text and borders. My
research suggests that the method GetPreferredSize() can tell me this.
I found this page:
http://windowsclient.net/blogs/faqs/archive/2006/07/12/how-do-control...
However, that page doesn't explain the ProposedSize argument, which is
required by the GetPreferredSize() method. Can anyone tell me how
ProposedSize is used by the GetPreferredSize() method?
-TC
Cor,
I'm trying to layout controls on a form. I've established logic to
arrange the controls neatly within the space available, adding scroll
bars when necessary. In order to do everything right, I need to
compute the minimum space required for each control at runtime. I've
seen code which figures out this minimum size by setting the AutoSize
property to True, then letting the control size itself, and
interpreting that size as the minimum size. However, I believe this is
the wrong approach because it requires two layout passes (one to
autosize the controls, then another for my arrangement), and also
because I simply don't want to autosize the controls; I want to give
them custom sizes.
I expect there is some method to programmatically determine the
minimum size for a control without having to autosize it first. I've
guessed that GetPreferredSize is that method. However, the
documentation for GetPreferredSize is very poor. In my experiments,
I've determined that GetPreferredSize(Size.Empty) works more or less
as I would expect, but I have no idea what it is supposed to do when
you provide it with a real ProposedSize argument.
Note that there are many ways to define the minimum size for a
control. A label, for instance, might fit inside both (200, 25) and
(100, 50), depending on whether its text is broken into two lines or
not. I'd like to think that ProposedSize somehow lets me control this.
I've experimented to see if GetPreferredSize(New Size(0, 0)) gives me
an answer of (200, 25) and if GetPreferredSize(New Size(0, 50)) gives
me an answer of (100, 50), but it doesn't work that way -- I always
get the answer (200, 25). [These numbers are hypothetical -- I can't
remember the real numbers I used.]
In any case, this entire effort is motivated by my desire to create
pretty, resizable forms. If you, Cor -- or other developers reading
this -- have never used the GetPreferredSize method, how to you get
your forms to layout properly?
-TC