G
Guest
Hi,
I'm new to VB.NET and I'm trying to do something rather simple that has
turned out to be a pain in the hindside.
I'm developing a webpart. All I want to do is change the font of a label on
it. The label is created at runtime. I use the following code:
Dim lblDate as Label = New Label
lblDate.Text = Date.Today
To change the font, I understand that you have to use the System.Drawing
class. Fine. I do that, but if I do this:
lblDate.Font = New System.Drawing.Font("Verdana", 12, Drawing.FontStyle.Bold)
Then I get the error "Font is Read-Only"
If I use this instead:
lblDate.Font = New System.Drawing.Font(lblDate.Font, Drawing.FontStyle.Bold)
Then I get the error "Overload resolution failed because no accessible New
can be called with these arguments"
So please. Can somebody tell me what I'm doing wrong? I just want to make
the font bigger and set it to a different style. It's really simple stuff. I
don't get why it's such an issue in VB.NET.
Thanks in advance,
KV
I'm new to VB.NET and I'm trying to do something rather simple that has
turned out to be a pain in the hindside.
I'm developing a webpart. All I want to do is change the font of a label on
it. The label is created at runtime. I use the following code:
Dim lblDate as Label = New Label
lblDate.Text = Date.Today
To change the font, I understand that you have to use the System.Drawing
class. Fine. I do that, but if I do this:
lblDate.Font = New System.Drawing.Font("Verdana", 12, Drawing.FontStyle.Bold)
Then I get the error "Font is Read-Only"
If I use this instead:
lblDate.Font = New System.Drawing.Font(lblDate.Font, Drawing.FontStyle.Bold)
Then I get the error "Overload resolution failed because no accessible New
can be called with these arguments"
So please. Can somebody tell me what I'm doing wrong? I just want to make
the font bigger and set it to a different style. It's really simple stuff. I
don't get why it's such an issue in VB.NET.
Thanks in advance,
KV