Click here to Skip to main content
15,895,822 members
Home / Discussions / C#
   

C#

 
QuestionResizing Controls According to Forms' Size Pin
AmbiguousName27-Dec-11 2:15
AmbiguousName27-Dec-11 2:15 
AnswerRe: Resizing Controls According to Forms' Size Pin
PIEBALDconsult27-Dec-11 2:29
mvePIEBALDconsult27-Dec-11 2:29 
AnswerRe: Resizing Controls According to Forms' Size Pin
David C# Hobbyist.27-Dec-11 2:34
professionalDavid C# Hobbyist.27-Dec-11 2:34 
AnswerRe: Resizing Controls According to Forms' Size Pin
Shameel27-Dec-11 4:08
professionalShameel27-Dec-11 4:08 
AnswerRe: Resizing Controls According to Forms' Size Pin
BillWoodruff27-Dec-11 4:38
professionalBillWoodruff27-Dec-11 4:38 
GeneralRe: Resizing Controls According to Forms' Size Pin
Roger Wright27-Dec-11 20:58
professionalRoger Wright27-Dec-11 20:58 
GeneralRe: Resizing Controls According to Forms' Size Pin
BillWoodruff29-Dec-11 2:31
professionalBillWoodruff29-Dec-11 2:31 
GeneralRe: Resizing Controls According to Forms' Size Pin
BobJanova30-Dec-11 14:44
BobJanova30-Dec-11 14:44 
One major reason for this looking crappy is that Windows picks a screen font with an integer pixel size. If you're resizing from 10 pixel by 85%, it's going to jump to 9, which is too big and your control alignment will be broken, or 8, which is too small and ditto. As you discovered, you can't really do this for UI.

In a real project at the moment I am doing exactly this on a graph, however, and it works pretty well there. That's because the text components (axis labels, captions, headers, value labels) are not aligned with each other in such a way that you notice the slight inconsistencies. I can also see how resizing the font in an individual text area might make sense. Standard control fonts, though, should be left alone because the user has certain expectations about those; even if you got your scaling working perfectly, it would be a nasty user experience.

You can 'scale' a font thus:
Font newFont = new Font(oldFont.FontFamily, newSize);


Ed: I'm not sure if Windows or the Framework caches font objects. If not, you're going to end up with a huge stack of wasted font resources if you implement arbitrary scaling, at least until the GC gets around to collecting them all (which might be a long, long time since you won't be running low on memory which is what it looks at).
GeneralRe: Resizing Controls According to Forms' Size Pin
BillWoodruff2-Jan-12 14:29
professionalBillWoodruff2-Jan-12 14:29 
AnswerRe: Resizing Controls According to Forms' Size Pin
RaviRanjanKr31-Dec-11 3:41
professionalRaviRanjanKr31-Dec-11 3:41 
Questionhow can we write large source code in 2 or more seperate units? Pin
Fred 3427-Dec-11 2:04
Fred 3427-Dec-11 2:04 
AnswerRe: how can we write large source code in 2 or more seperate units? Pin
PIEBALDconsult27-Dec-11 2:30
mvePIEBALDconsult27-Dec-11 2:30 
GeneralRe: how can we write large source code in 2 or more seperate units? Pin
Shameel27-Dec-11 3:32
professionalShameel27-Dec-11 3:32 
GeneralRe: how can we write large source code in 2 or more seperate units? Pin
Tosche Station27-Dec-11 3:55
Tosche Station27-Dec-11 3:55 
AnswerRe: how can we write large source code in 2 or more seperate units? Pin
AmitGajjar27-Dec-11 3:10
professionalAmitGajjar27-Dec-11 3:10 
AnswerRe: how can we write large source code in 2 or more seperate units? Pin
Shameel27-Dec-11 3:34
professionalShameel27-Dec-11 3:34 
AnswerRe: how can we write large source code in 2 or more seperate units? Pin
#realJSOP27-Dec-11 4:08
mve#realJSOP27-Dec-11 4:08 
GeneralRe: how can we write large source code in 2 or more seperate units? Pin
PIEBALDconsult27-Dec-11 4:29
mvePIEBALDconsult27-Dec-11 4:29 
GeneralRe: how can we write large source code in 2 or more seperate units? Pin
Shameel27-Dec-11 4:42
professionalShameel27-Dec-11 4:42 
GeneralRe: how can we write large source code in 2 or more seperate units? Pin
PIEBALDconsult27-Dec-11 4:56
mvePIEBALDconsult27-Dec-11 4:56 
GeneralRe: how can we write large source code in 2 or more seperate units? Pin
Shameel27-Dec-11 5:09
professionalShameel27-Dec-11 5:09 
GeneralRe: how can we write large source code in 2 or more seperate units? Pin
PIEBALDconsult27-Dec-11 5:30
mvePIEBALDconsult27-Dec-11 5:30 
GeneralRe: how can we write large source code in 2 or more seperate units? Pin
#realJSOP27-Dec-11 7:37
mve#realJSOP27-Dec-11 7:37 
GeneralRe: how can we write large source code in 2 or more seperate units? Pin
Shameel27-Dec-11 8:02
professionalShameel27-Dec-11 8:02 
GeneralRe: how can we write large source code in 2 or more seperate units? Pin
PIEBALDconsult27-Dec-11 8:28
mvePIEBALDconsult27-Dec-11 8:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.