|
-
Nov 16th, 2009, 04:29 PM
#1
Thread Starter
Member
amend readonly properties
hi
How do i amend the read only properteis like font.underline, font.height etc
I know its read only but there must be a way to amnd these.
This is for writing fractions in vb
-
Nov 16th, 2009, 04:40 PM
#2
Addicted Member
Re: amend readonly properties
If you want to set the font style for example a label, you have to construct a new font, and assign that font to the label. Something like this...
Code:
Label1.Font = New Font("Microsoft Sans Serif", 11, FontStyle.Underline)
Not quite sure if that's what you wanted though...
-
Nov 16th, 2009, 07:02 PM
#3
Re: amend readonly properties
Note that, if you want to change the style of an existing Font, there's a constructor provided specifically for that:
vb.net Code:
'Apply the Bold style. myFont = New Font(myFont, myFont.Style Or FontStyle.Bold) 'Remove the Bold style. myFont = New Font(myFont, myFont.Style And Not FontStyle.Bold) 'Toggle the Bold style. myFont = New Font(myFont, myFont.Style Xor FontStyle.Bold)
Just to elablorate a bit, Font objects are immutable by design. That means that, once created, you cannot change a Font. The reason for this is that making them changeable would require the class to be considerably more complex and Microsoft decided that keeping the class lightweight was preferable to making it mutable.
-
Nov 17th, 2009, 03:16 AM
#4
Thread Starter
Member
Re: amend readonly properties
Thanks, the underline worked. What if I want to change the line spacing i.e reduce them.
-
Nov 17th, 2009, 03:58 AM
#5
Re: amend readonly properties
As far as I'm aware the Height of a Font is determined by the creator of the font, not the user. If you want more space between your lines then you need to use GDI+ to draw the text and add the padding yourself.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|