Search:
Namespaces
Discussions
.NET v1.1
Feedback
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
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com