Hi,

I just wonder if anyone can help me with this:

I need to be able to resize a form by setting the size of its client area.
Say, in Delphi i would do so:

Form1.ClientHeight = 10;
Form1.ClientWidth = 20;

And the form will adjust its size so that client area will be as set.

In .NET Form class there is a ClientRectangle property but it's
read-only and trying to change any of it's properties causes a compile
error:

//-----------------------------------------
Form1.cs(78): Cannot modify the return value of
'System.Windows.Forms.Control.ClientRectangle' because it is not a variable
//-----------------------------------------


Any ideas?

Thank you,
Andrey

Re: Resizing a form by client height/width by MuZZy

MuZZy
Tue Dec 28 10:56:42 CST 2004

MuZZy wrote:
> Hi,
>
> I just wonder if anyone can help me with this:
>
> I need to be able to resize a form by setting the size of its client area.
> Say, in Delphi i would do so:
>
> Form1.ClientHeight = 10;
> Form1.ClientWidth = 20;
>
> And the form will adjust its size so that client area will be as set.
>
> In .NET Form class there is a ClientRectangle property but it's
> read-only and trying to change any of it's properties causes a compile
> error:
>
> //-----------------------------------------
> Form1.cs(78): Cannot modify the return value of
> 'System.Windows.Forms.Control.ClientRectangle' because it is not a variable
> //-----------------------------------------
>

Ok, if someone is interested - use ClientSize prop of Form:
Form.ClientSize = new Size(height, width);