This is a very basic question here. I must be missing something
here.
At run time, I am trying to set the text of the label control bold.
lblMyLabel.Font.Bold = true;
does not work since it's read only (why why why why why).
Thank you.
Hello David,
>At run time, I am trying to set the text of the label control bold.
>
>lblMyLabel.Font.Bold = true;
>
>does not work since it's read only
Use a line like this instead:
label1.Font.Bold = new Font(label1.Font, FontStyle.Bold);
Oliver Sturm

Signature
http://www.sturmnet.org/blog
David C - 01 Feb 2007 21:32 GMT
> Hello David,
>
[quoted text clipped - 10 lines]
> Oliver Sturm
> --http://www.sturmnet.org/blog
Thank you. I can't think of a rhyme or reason why Font.Bold property
should be read only. Can you?
Oliver Sturm - 01 Feb 2007 21:57 GMT
Hello David,
>Thank you. I can't think of a rhyme or reason why Font.Bold property
>should be read only. Can you?
Well... sure ;-)
The whole Font handling goes back onto Windows resources outside .NET. On
the API level it's simply not possible to set a property Bold on the font
- after all, for a lot of fonts it's a different font resource that is
being loaded for bold or non-bold display. Check your Windows\Fonts folder
and you'll see that there are several arial*.ttf files - one of them is
the bold version of Arial.
Of course the .NET API could theoretically hide that detail from you and
make the Bold property writable nevertheless. But they decided not to go
that way and I can understand why - the way things are, the user of the
API understands that he's triggering what may be a costly operation.
Otherwise it would have seemed like switching the Bold flag may be a
trivial thing without a lot of overhead.
Oliver Sturm

Signature
http://www.sturmnet.org/blog