|
-
Nov 24th, 2008, 01:02 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Changing Fonts at Runtime ?
Well i am making a Notepad Program with some useful Functions now im hanging here:
I loaded all Fonts to a Combobox like this:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim installed_fonts As New InstalledFontCollection
For Each font_family As FontFamily In installed_fonts.Families
tscb_font.Items.Add(font_family.Name)
Next
End Sub
Now ok that works now i want to switch the Font i did this but it doesent work:
Code:
rtb_text.Select()
rtb_text.SelectionFont = tscb_font.Font
All Fonts are in the Combobox so i only need to know how to switch the Fonts...
But it doesent work i hope you guys can help me =)
-
Nov 24th, 2008, 01:14 PM
#2
Re: Changing Fonts at Runtime ?
Code:
'make sure selection is made in combo
if tscb_font.selectedindex = -1 then return
'set selectedtext to given font
rtb_text.SelectionFont = new font(tscb_font.text, put size here)
This will work, however it is unclear if you are looking to change the ENTIRE text of the RTB when you select a new font, or just the selected text. Just like Word, but unlike Notepad, the RTB can handle different fonts on text inside it. If you wanted to change the entire font of all the text when you change the selection, then just assign the font to the RTBs Font property instead of its SelectionFont property.
You also need to specify a size you want the font to be. If you want to use the existing size of the existing font, you could do something like
Code:
rtb_text.SelectionFont = new font(tscb_font.text, SelectionFont.Size)
-
Nov 24th, 2008, 01:35 PM
#3
Thread Starter
Addicted Member
Re: Changing Fonts at Runtime ?
 Originally Posted by kleinma
Code:
'make sure selection is made in combo
if tscb_font.selectedindex = -1 then return
'set selectedtext to given font
rtb_text.SelectionFont = new font(tscb_font.text, put size here)
This will work, however it is unclear if you are looking to change the ENTIRE text of the RTB when you select a new font, or just the selected text. Just like Word, but unlike Notepad, the RTB can handle different fonts on text inside it. If you wanted to change the entire font of all the text when you change the selection, then just assign the font to the RTBs Font property instead of its SelectionFont property.
You also need to specify a size you want the font to be. If you want to use the existing size of the existing font, you could do something like
Code:
rtb_text.SelectionFont = new font(tscb_font.text, SelectionFont.Size)
Ok thx works perfect =)
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
|