.NETGURU
SuspendLayout breaks Inherited form
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.windowsforms.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Gravy (VIP)
Hi there,

This must be a common question but I can't find the answer.

I have a simple windows forms project. I create a form with say an OK and
Cancel button anchored to the bottom of the window. I compile the project.
Next I create a new form inherited from the previous. I add a label to it and
compile the code. Everything is ok. If I change the size of the derived form
(make it smaller) and then recompile I can nolonger see the buttons that were
on the base form.

Looking at the auto generated code in the derived class it seems to have
place a SuspendLayout and ResumeLayout around everything, including the call
the set the ClientSize of the form, hence the base classes buttons are not be
repositioned after the new size.

The code in the derived class is:

this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
// linkLabel1
//
this.linkLabel1.Location = new System.Drawing.Point(256, 8);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.TabIndex = 3;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "linkLabel1";
//
// Form3
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(384, 118);
this.Controls.Add(this.linkLabel1);
this.Name = "Form3";
this.Controls.SetChildIndex(this.linkLabel1, 0);
this.ResumeLayout(false);

If I manualyy move the this.ClientSize = line to after the ResumeLayout
everything works ok.

Is this a feature, bug or my mistake. Does anyone know if there is a way
round it?

Thanks for your help.
Reply to this message...
 
    
Gravy (VIP)
BTW, I'm using v1.1 of the framework on WinXP.

"Gravy" wrote:

[Original message clipped]

Reply to this message...
 
    
Joey Calisay
I believe this is a bug on anchoring. I've experienced it and thankful to
Weigelt's article at

weblogs.asp.net/rweigelt/archive/2003/09/24/28984.aspx

"Gravy" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Gravy (VIP)
Thanks Joey,

that blog was excellant and fixed my problems.

In case you don't know, the problem with using Anchor in base forms seems to
be fixed in VS 2005 (Beta1 anyway ;-) ).

Graham

"Joey Calisay" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.Drawing.Point
System.Drawing.Size
System.Windows.Forms.LinkLabel




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification