CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Brendan Tompkins [MVP]

Blog First. Ask Questions Later.

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



Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Brendan Tompkins

Brendan has been programming with .NET since the first public beta and is owner and operator of Port Technology Services, a consultancy company providing .NET application development services to the Maritime industry. In July, 2007, he was awarded the Microsoft MVP award for ASP.NET. He's also a proud co-founder of failed .COM startup Intrinsigo, and has had a hand in the failure of numerous other businesses. He currently runs CodeBetter.Com and Devlicio.us, and lives in Norfolk, Virgina with his wife Tiara and son Ian.

View Brendan's profile on LinkedIn

Check out Devlicio.us!

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News

MVP
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.