1

I want to allow the user to change the font while using the app. For example, my user typed the first paragraph in arial font, 12 pt; then next paragraph he can type in another font with a different size.

The problem I am facing is when I change a font, the entire font of the text field is changing.

Code is:

if (comboBox1.SelectedIndex == 1)
{
    richTextBox1.Font = 
        new Font(richTextBox1.Font.FontFamily, 12, FontStyle.Italic);
}
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
  • 2
    Is this the [winforms richtext box](https://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox(v=vs.110).aspx) or the [WPF richtext box](https://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox(v=vs.110).aspx)? – 15ee8f99-57ff-4f92-890c-b56153 Oct 31 '16 at 14:30
  • [See here](http://stackoverflow.com/questions/26700102/how-to-change-the-font-of-multiple-sizes-in-richtextbox-in-c/26701034#26701034) – TaW Oct 31 '16 at 15:23
  • Also, see [Changing font for RichTextBox without losing formatting](http://stackoverflow.com/a/16307021/719186) – LarsTech Nov 01 '16 at 16:22

1 Answers1

1

The way you have it coded now, it is referencing the entire richTextBox1. You can try using richTextBox1.SelectionFont =... to change the font of just the section you have chosen.

https://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.selectionfont(v=vs.110).aspx

Jret
  • 90
  • 1
  • 13