I am trying to create a Shortcut element that automatically displays its text in bold.
My environment is a C # Windows Forms application using .NET 3.5, Visual Studio 2010 SP1, Windows 7 Professional, SP1, a 32-bit processor.
My current implementation is shown below.
The only requirement I have for this bold Label control is that it should behave exactly like the standard System.Windows.Forms.Label control (both programmatically and in the WinForm designer environment), except that he uses bold to draw his text.
Below are some problems with the current implementation:
I intend to use this bold shortcut control in many places of a large application, resulting in hundreds of instances of this control being executed at runtime. Am I really creating new font objects? Should these font objects be deleted? If so, when?
I want to make sure that when I localize my application (set the Localizable property to true for the parent container), this bold label will work well with the WinForm resource serialization mechanism. In other words, if I drop this bold label on the Windows form, then set Localizable to true for the form, and then click Save, Visual Studio will serialize my form resources in MyForm.Designer.cs. This will include an instance of my bold label management. Will my font installation implementation for my bold label ruin this resource serialization mechanism?
Is there a more efficient / clean implementation? Other issues to consider?
[Code Follows]
namespace WindowsFormsApplication1 { using System.ComponentModel; using System.Drawing;
source share