Re: Form is not displayed at the correct (designer) size. by Emmanuel
Emmanuel
Wed Jun 01 05:05:33 CDT 2005
Hi Jeffrey,
I understand the ClientSize and Size stuff. I new all this from the
beginning. I new that if I specify the Size of the form in code then
everything would work fine.
The workaround is not so "very simple" because the workaround you are
suggesting cancels the usage of the designer in building windows forms.
The workaround you suggest works as follows:
1. The programmer designs a form using the designer.
2. After finishing the design process, the programmer reads the values held
at the Size property of the form.
3. The programmer includes a line in his code that programmatically sets the
Size of the Form.
..4. If the programmer changes the size of the form, later, he should
complete all steps from 1 to 3 in order for the form to work correctly.
I consider this a serious Microsoft VS.NET 2003 bug.
Anyway thanks for the help.
Emmanuel
""Jeffrey Tan[MSFT]"" <v-jetan@online.microsoft.com> wrote in message
news:9EAnGbbZFHA.3928@TK2MSFTNGXA01.phx.gbl...
> Hi Emmanuel,
>
> Thanks for your feedback!
>
> Sorry, it seems that I mis-looked your word "Size" as "Location". Oh, yes,
> in my sample project, I can reproduce the "Size" changing problem.
>
> First, it seems that this problem only occurs when we uses VS.net designer
> to set OtherForm's properties. Based on my research, I found that in
> VS.net
> designer, the setting for Form.Size property will not generate code for
> Form.Size property, instead, it will generate code for Form.ClientSize
> property. For example, if I set Form.Size to "500,300" in propetybrowser,
> the code generated in InitializeComponent() will be like this:
> this.ClientSize = new System.Drawing.Size(494, 275);
>
> If we change this statement to this.Size=new Size(500, 300), then
> everything will work well. So I think this should be the problem of VS.net
> designer code generator.
>
> The reason for this issue is that when we set
> f.FormBorderStyle=FormBorderStyle.FixedDialog, it internally will set
> form's border style to a width value which is different from(actually less
> than) the default FormBorderStyle.Sizable(which should be 500-494=6 and
> 300-275=25). Then, when the form shows out, the result total size will be
> less than (500, 300).
>
> Anyway, the workaround for this issue is very simple, just use an explicit
> Form.Size calling in place of Form.ClientSize code statement.
>
> Hope this helps
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>