Click here to Skip to main content
14,392,909 members
Rate this:
Please Sign up or sign in to vote.
See more:
These three line define under below how to change Font programmatically



Arial	‘ Change Font / Font Size
Thoma	‘ Change Font / Font Size
Calibri   ‘Change Font  / Font Size


What I have tried:

RtbBox.Text += Environment.NewLine + "Thoma"
        RtbBox.Text += Environment.NewLine + "Arial"
        RtbBox.Text += Environment.NewLine + "Calibiri"


RtbBarcodeLinesGenerate.SelectionFont = New Font("Thoma", 16, FontStyle.Regular)

RtbBox.SelectionFont = New Font(RtbBox.Font.FontFamily, RtbBox.Font.Size, FontStyle.Bold)
Posted
Updated 24-Mar-19 9:35am
Comments
Mohibur Rashid 24-Mar-19 8:41am
   
What is the problem?
Rate this:
Please Sign up or sign in to vote.

Solution 1

Try This.

Font f = new Font("Arial", 14);
RtbBox.SelectAll();
RtbBox.SelectionFont = f;
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Based on the example from MSDN forum: Making Specific Lines Bold in a RichTextBox- VB.NET[^]

'lines(0)
RichTextBox1.SelectionStart = RichTextBox1.GetFirstCharIndexFromLine(0)
RichTextBox1.SelectionLength = RichTextBox1.Lines(0).Length
RichTextBox1.SelectionFont = New Font("Thoma", 16, FontStyle.Regular)
'lines(1)
RichTextBox1.SelectionStart = RichTextBox1.GetFirstCharIndexFromLine(1)
RichTextBox1.SelectionLength = RichTextBox1.Lines(1).Length
RichTextBox1.SelectionFont = New Font("Arial", 14, FontStyle.Bold)
'lines(2)
RichTextBox1.SelectionStart = RichTextBox1.GetFirstCharIndexFromLine(2)
RichTextBox1.SelectionLength = RichTextBox1.Lines(2).Length
RichTextBox1.SelectionFont = New Font("Calibiri", 12, FontStyle.Italic)


[EDIT]
Above code can be "converted" into procedure. See: Programatically Add Formatted Font To Richtextbox - VB.NET | Dream.In.Code[^]

Good luck!
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100