|
-
Sep 17th, 2000, 05:08 AM
#1
Hi!
Still working on my NotePad thing. My problem is that I don't know hoe to change the font and/or size on the marked text. And another problem is that when i mark a text and then click my ComboBox, the text gets unmarked. Plz, help me!
/ Erik
-
Sep 17th, 2000, 06:17 AM
#2
I assume you're using a RichTextBox because you can't do this with the original textbox.
Code:
RichTextBox1.SelFontName = "Times New Roman"
RichTextBox1.SelFontSize = 16
The text isn't really deselected when the textbox loses focus but it's rather hidden.
If you don't want this behaviour set the HideSelection property to False at design time.
Good luck!
PS. Hur är livet i Linköping DS.
-
Sep 17th, 2000, 07:54 AM
#3
Thanks for the help!
PS. Bara bra =) DS.
-
Sep 17th, 2000, 08:00 AM
#4
Oops
Hi again!
The code you gave me didn't work! I don't know why. This is how it looks like:
Private Sub chooseFont_Change()
text.SelFontName = chooseFont.Value
End Sub
What do u think?
/ Erik
-
Sep 17th, 2000, 10:47 AM
#5
You need to use a RichTextBox to do this.
[Edited by Megatron on 09-17-2000 at 11:54 AM]
-
Sep 17th, 2000, 11:02 AM
#6
I just finished writing an example of working with formatted text. Add the following code to a Form with a RichTextBox, CommonDialog and a CommandButton.
Code:
On Error Resume Next
With CommonDialog1
.Flags = cdlCFBoth Or cdlCFEffects
.FontBold = RichTextBox1.SelBold
.FontItalic = RichTextBox1.SelItalic
.FontUnderline = RichTextBox1.SelUnderline
.FontStrikethru = RichTextBox1.SelStrikeThru
.FontName = RichTextBox1.SelFontName
.FontSize = RichTextBox1.SelFontSize
.Color = RichTextBox1.SelColor
End With
CommonDialog1.ShowFont
If Err <> 32755 Then
With RichTextBox1
.SelBold = CommonDialog1.FontBold
.SelItalic = CommonDialog1.FontItalic
.SelUnderline = CommonDialog1.FontUnderline
.SelStrikeThru = CommonDialog1.FontStrikethru
.SelFontName = CommonDialog1.FontName
.SelFontSize = CommonDialog1.FontSize
.SelColor = CommonDialog1.Color
End With
End If
When you select text in the RichTextBox then click the button, the FontDialog Box will appear and from there, you can format your text.
-
Sep 17th, 2000, 12:29 PM
#7
Won't work!
Hi!
It won't just work! An alert box pops up and say:
Compile Error:
Invalid Outside procedure
/ Erik
PS. I have added RichTextBox, CommonDialog and CommandButton, and I haven't changed there names. DS.
-
Sep 17th, 2000, 12:34 PM
#8
What line are you getting it on?
-
Sep 17th, 2000, 12:52 PM
#9
Guru
Put it in the CommandButton. 
Code:
Private Sub Command1_Click()
' Megatron's code here
End Sub
-
Sep 17th, 2000, 01:17 PM
#10
Now it worked. My bad =)
But that wasn't really how I wanted it. I was thinking more like word, y'know, with these buttons. But thx anyway! I will proborbly use this in an other program.
/ Erik
-
Sep 18th, 2000, 09:06 AM
#11
Re: Oops
Originally posted by TimeHero
Hi again!
The code you gave me didn't work! I don't know why. This is how it looks like:
Private Sub chooseFont_Change()
text.SelFontName = chooseFont.Value
End Sub
I assume chooseFont is the ComboBox.
The Change event of a ComboBox will only be fired when the user types in the textbox area. When you click to choose an item in the drop down list box the Click event is fired.
So just move the code to the Click event.
Code:
Private Sub chooseFont_Click()
text.SelFontName = chooseFont.List(chooseFont.ListIndex)
End Sub
Good luck!
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
|