|
-
Jul 6th, 2005, 11:01 AM
#1
Thread Starter
Lively Member
Font/Combo Box Thing
using This Site: http://www.developerfusion.co.uk/show/1659/
I Have Made A Combo Box On My Form, Combo 1 And A Module, Module1
I Have added the code it says on this site and all the fonts are listed in the combo box, now how do i get the font in the combo box to change the font in the richtextbox i am using, called richtextbox1
-
Jul 6th, 2005, 11:03 AM
#2
Re: Font/Combo Box Thing
something like
VB Code:
richtextbox1.selfont = combobox1.value
should work
-
Jul 6th, 2005, 11:08 AM
#3
Thread Starter
Lively Member
-
Jul 6th, 2005, 11:13 AM
#4
Re: Font/Combo Box Thing
I just noticed there is
richtextbox1.selfontname
and
richtextbox1.selfontsize
those should work
-
Jul 6th, 2005, 11:19 AM
#5
Thread Starter
Lively Member
Re: Font/Combo Box Thing
i have this
VB Code:
Private Sub Combo2_Change()
RichTextBox1.SelFontName = Combo2.Text
End Sub
and it still doesn't work
-
Jul 6th, 2005, 11:20 AM
#6
Re: Font/Combo Box Thing
try combo2.value
and what exactly is listed in the combobox? because the command selfontname would only work with something like "Times New Roman" or another font name in that general format
-
Jul 6th, 2005, 11:28 AM
#7
Thread Starter
Lively Member
Re: Font/Combo Box Thing
i tried .value
and it isn't a propetry of the combobox
-
Jul 6th, 2005, 11:29 AM
#8
Re: Font/Combo Box Thing
 Originally Posted by kfcSmitty
and what exactly is listed in the combobox? because the command selfontname would only work with something like "Times New Roman" or another font name in that general format
So whats lsited in ur combobox? can you take a screenshot?
-
Jul 6th, 2005, 11:34 AM
#9
Thread Starter
Lively Member
Re: Font/Combo Box Thing
just all the fonts installed on my PC, and if it was run on someone elses, it would have all of their fonts
-
Jul 6th, 2005, 11:38 AM
#10
Re: Font/Combo Box Thing
so it displays them like
"Wingdings"
"Times New Roman"
"Arial"
?
because I just tried that and it works fine...
-
Jul 6th, 2005, 11:40 AM
#11
Thread Starter
Lively Member
Re: Font/Combo Box Thing
yeah, it says from A-Z in alphabetical order like this
Arial
Times New Roman
etc. with no speech marks ""
-
Jul 6th, 2005, 11:41 AM
#12
Re: Font/Combo Box Thing
you realise with .selfontname you have to have the text selected right?
I have also noticed that with the combo1_change event, it takes focus away from the textbox, thus unhighlighting the text
-
Jul 6th, 2005, 11:45 AM
#13
Thread Starter
Lively Member
Re: Font/Combo Box Thing
yeah, i also noticed that,
-
Jul 6th, 2005, 11:46 AM
#14
Re: Font/Combo Box Thing
VB Code:
RichTextBox1.Font.Name = Combo1.Text
-
Jul 6th, 2005, 11:56 AM
#15
Thread Starter
Lively Member
-
Jul 6th, 2005, 11:58 AM
#16
Re: Font/Combo Box Thing
the code itself works..you just need to find a way to keep the text selected while changing the combo box
maybe store the selstart and sellength in a variable and right before you change the font, rehighlight the text?
-
Jul 6th, 2005, 12:05 PM
#17
Thread Starter
Lively Member
Re: Font/Combo Box Thing
how would i code this, i'm rather new to VB
-
Jul 6th, 2005, 12:12 PM
#18
Re: Font/Combo Box Thing
 Originally Posted by lavarock09
I Have Made A Combo Box On My Form, Combo 1 And A Module, Module1
I Have added the code it says on this site and all the fonts are listed in the combo box, now how do i get the font in the combo box to change the font in the richtextbox i am using, called richtextbox1
Attached is a one form project with a richtextbox and a combo box. If you run it, the font in the richtextbox will change to whatever font you select from the combo.
This is what you are after, correct?
-
Jul 6th, 2005, 12:19 PM
#19
Re: Font/Combo Box Thing
VB Code:
'Declarations
Dim SelectionStart As Integer
Dim SelectionLength As Integer
Private Sub Combo2_Click()
RichTextBox1.SetFocus
DoEvents
RichTextBox1.SelStart = SelectionStart
RichTextBox1.SelLength = SelectionLength
RichTextBox1.SelFontName = Combo1.Text
End Sub
Private Sub RichTextBox1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
SelectionStart = RichTextBox1.SelStart
SelectionLength = RichTextBox1.SelLength
End Sub
this works for me
-
Jul 6th, 2005, 12:21 PM
#20
Thread Starter
Lively Member
Re: Font/Combo Box Thing
thanx, that does what i wanted, thanx
-
Jul 6th, 2005, 12:25 PM
#21
Thread Starter
Lively Member
Re: Font/Combo Box Thing
I Do have 2 Other Things i couldn't do,
1. was to have a character count on,
2. was to be able to right click my rtb and see the edit menu, cut, copy paste etc
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
|