Hi,
In the application I'm developing , we use the DevExpress XtraGrid control, which has a RowCellStyle
event that allows to customize the style of each cell. The event handlers for this event typically look like that :
private gridView1_RowCellStyle(object sender, RowCellStyleEventArgs e)
{
if (/* Some condition */)
{
e.Appearance.Font = new Font(gridView1.Appearance.Font, FontStyle.Bold);
}
}
This handler is called every time a cell is rendered, so it can create a large number of Font
instances. So I'm wondering about the cost of doing that... I did a few experiments, and it seems that a new HFONT handle is created every time. Should I worry about it ? How big is the impact on resource usage ?
If it has a significant performance impact, shouldn't there be a FontCache
class or something similar ?
Note : I know how to solve the problem (I just need to create the font once and reuse it every time), my question is really about the cost of creating many HFONT handles