Is there a way to change the font size per line.

say something like an array of strings

for(i=0;i<10;i++)

{
if(i > 5)

myRichBox.AppendText("<size=30>" + mystring[i] + "</size>");
else

myRichBox.AppendText("<size=20>" + mystring[i] +"</size>");
}

Three steps:

  1. Set the position of the start of the selected text
  2. Set the length of the selected text
  3. Change the font size by specifying a new font with only the size changed

Example - Let's assume a RichTextBox named rtb (for brevity). Let's say you want to change the font size to 20.

rtb.Text = "abcde" & vbCrLf & "fghij" & vbCrLf & "klmno"
rtb.SelectionStart = 6
rtb.SelectionLength = 5
rtb.SelectionFont = New System.Drawing.Font(rtb.SelectionFont.FontFamily.Name, 20.0F, rtb.SelectionFont.Style, System.Drawing.GraphicsUnit.Point)

If you want to let the user select text and make it big then you can just add btnBig with the following code

Private Sub btnBig_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBig.Click
    rtb.SelectionFont = New System.Drawing.Font(rtb.SelectionFont.FontFamily.Name, 20.0F, rtb.SelectionFont.Style, System.Drawing.GraphicsUnit.Point)
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.