Welcome to Dream.In.Code
Click Here
Getting VB.NET Help is Easy!

Join 117,523 VB.NET Programmers for FREE! Ask your question and get quick answers from experts. There are 2,036 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Font Issue

 
Reply to this topicStart new topic

Font Issue, How can I have separate fonts in one text box.

gbertoli3
post 1 Jul, 2008 - 10:28 AM
Post #1


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 777



Thanked 11 times

Dream Kudos: 675
My Contributions


How can I have separate fonts in one text box? Such as having some text be bold, italic, underline, different font family, and different font size.

What I am trying to do is have the font apply only to the selectedText.

I would show you my code but I have no idea even how to start this code.


Thanks
User is online!Profile CardPM

Go to the top of the page


PsychoCoder
post 1 Jul, 2008 - 10:42 AM
Post #2


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,829



Thanked 79 times

Dream Kudos: 8050

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI, Boo.Net

My Contributions


You're going to want to use a RichTextBox for this, but first are you using VB6 or some other version? That has a bearing on which direction you want to go
User is offlineProfile CardPM

Go to the top of the page

gbertoli3
post 1 Jul, 2008 - 10:55 AM
Post #3


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 777



Thanked 11 times

Dream Kudos: 675
My Contributions


QUOTE(PsychoCoder @ 1 Jul, 2008 - 10:42 AM) *

You're going to want to use a RichTextBox for this, but first are you using VB6 or some other version? That has a bearing on which direction you want to go



Oh a rich text box

I am using Visual Studio 2008 so I think that it is VB9 or something like that but I am really not sure
User is online!Profile CardPM

Go to the top of the page

PsychoCoder
post 1 Jul, 2008 - 11:25 AM
Post #4


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,829



Thanked 79 times

Dream Kudos: 8050

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI, Boo.Net

My Contributions


Well in that case Im moving this to the VB.NET forum, that way it can get the proper attention. In the mean time heres an example of the SelectionFont, SelectedText and SelectedColor properties of the RichTextBox


vb

Private Sub WriteTextToRichTextBox()
' Clear all text from the RichTextBox;
richTextBox1.Clear()
' Set the font for the opening text to a larger Arial font;
richTextBox1.SelectionFont = New Font("Verdana", 16)

' Assign the introduction text to the RichTextBox control.
RichTextBox1.SelectedText = "Lets make this text in Verdana, and in Green" + Environment.NewLine

'Set the color
richTextBox1.SelectionColor = Color.Green;

' Set the Font for the first item to a smaller size Arial font.
richTextBox1.SelectionFont = New Font("Arial", 12)

' Set the color of the item text.
richTextBox1.SelectionColor = Color.Red

' Assign the text to the bulleted item.
richTextBox1.SelectedText = "Here is some more text that is Arial and Red" + Environment.NewLine

' Apply same font since font settings do not carry to next line.
richTextBox1.SelectionFont = New Font("Tahoma", 12)
richTextBox1.SelectionColor = Color.Orange
richTextBox1.SelectedText = "And one last bit of text in Tahoma and Orange" + Environment.NewLine

End Sub


Hope that Helps smile.gif
User is offlineProfile CardPM

Go to the top of the page

gbertoli3
post 1 Jul, 2008 - 02:27 PM
Post #5


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 777



Thanked 11 times

Dream Kudos: 675
My Contributions



Thanks it does help.
User is online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/7/08 03:24PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month