Brendan Tompkins [MVP]

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Copying Font Properties

Say you have a user control that contains some other web controls, such as a text box or drop down list.  Now say that you want the UI designer to be able to set the font properties of the contained controls, by setting the font properties of the control in the designer.  Well, if you've ever tried this:

this.myContainedControl.Font = this.Font;

You'll find that the Font property is read only.  You can set the individual properties, but this would be a pain for all of the properties that the FontInfo object supports.  Luckily, the FontInfo object has a CopyFrom method, which you can use to do accomplish this task in one fell swoop:

this.myContainedControl.Font.CopyFrom(this.Font);

Music tip o' the day: If you like REM, check out Placebo


Posted 10-15-2003 10:15 AM by Brendan Tompkins
Filed under:

[Advertisement]

Comments

Steve wrote re: Copying Font Properties
on 10-15-2003 6:35 AM
Nice! Why couldn't you have posted this a couple of months ago when I was trying to figure out why they would make it such a pain to copy font's between controls? :) Thanks for the tip!

Add a Comment

(required)  
(optional)
(required)  
Remember Me?