Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
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 8:35am
Comments
Mohibur Rashid 24-Mar-19 8:41am    
What is the problem?

Try This.

Font f = new Font("Arial", 14);
RtbBox.SelectAll();
RtbBox.SelectionFont = f;
 
Share this answer
 
Based on the example from MSDN forum: Making Specific Lines Bold in a RichTextBox- VB.NET[^]

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!
 
Share this answer
 
v2
Comments
Member 13456138 1-Jun-20 13:55pm    
Window Application C# .I set TextBox font 'Kundli' but when i am getting string from Textbox.Text then it will return 'ghjk' in place of 'हीरा'
Maciej Los 1-Jun-20 15:20pm    
And?
If you want to get help, you can Ask a question

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900