PC Review


Reply
Thread Tools Rate Thread

Derived Forms resizing in dotnet. (Fix)

 
 
Tony
Guest
Posts: n/a
 
      10th Aug 2004
Derived Forms resizing in dotnet. (Fix)

Problem:

If you have a form base class:

public frmBase : System.Windows.Forms
{
public frmBase {
// DefaultFormFont is new Font("Tahoma", 10);
this.font = SomeOtherClassFullofConstants.DefaultFormFont;
}

....
}

But the designer shows the font as MS Sans Serif, 8.25ft (The default
value).

Then you create a derived form

public class frmDerived : frmBase { }

But in the designer, you choose the font to be Tahoma 10.

Unexpected:
On each subsequent build, the frmDerived form will grow in size
linearly, that includes bigger controls, larger form size, and greater
spacing. It only takes 5 or 6 builds before things get very large. But
only if it is open in the designer view (I think, not sure).

Unexpected#2:
If you change
public class frmDerived : frmBase { }
to
public class frmDerived : Forms { }

Then it will shrink back, but only if it just enlarged, very funky.

Solution

Make the font the same in the designer of both frmBase and frmDerived.
That means remove it from the constructor.

From some other Google messages, it also looks like you should do:

using SomeNameSpace.Base;
//…
public class frmDerived : frmBase

and NOT

// BADC0DE
public class frmDerived : SomeNameSpace.Base.frmBase
// BADC0DE

Not sure why, looks like voodoo, but it could be worse...

--
Tony
Stratton

P.S. This took me awhile to figure out, hopefully you can benefit from
my time. Well, my companies time...

P.P.S (..."bigger" controls, "larger" form size, and "greater"...) I
used three synonyms to enhance Google search-ability. I wish that the
MotherShip (MS) would do this with their MSDN search.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Host a windows forms Form derived class in IE. Marcos Microsoft Dot NET Framework Forms 1 7th Nov 2008 03:09 AM
THE FOLDER DERIVED KEEPS SHOWIN UP IN FORMS WANT IT GONG ArtR5712 Microsoft Frontpage 2 4th Apr 2008 09:00 AM
forms designer loads slow with derived control PGP Microsoft C# .NET 2 13th Apr 2007 04:26 PM
Unable to Design Derived Forms Paul Cheetham Microsoft C# .NET 2 17th May 2006 12:21 PM
Friend modifier and derived forms Chris Leffer Microsoft Dot NET Framework Forms 3 8th Dec 2003 09:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:34 PM.