Work consists that I put on different pieces of the text different styles and type size. And then select all the changed pieces and put them one font. The result should be: the text is selected in the ComboBox font, and their styles and sizes do not change without authorization. At the moment everything happens the other way around. I put pieces of text in different styles and sizes, select everything, put all one font and all previous formatting flies.
Here is what is available:
private void FontBox_SelectedIndexChanged(object sender, EventArgs e) { if (RichTextBox.SelectionFont != null) { RichTextBox.SelectionFont = new Font(FontBox.Text, RichTextBox.SelectionFont.Size, RichTextBox.SelectionFont.Style); } RichTextBox.Select(); } private void SizeBox_SelectedIndexChanged(object sender, EventArgs e) { float size = 12; if (SizeBox.Text != string.Empty) { size = Convert.ToSingle(SizeBox.Text); } RichTextBox.SelectionFont = new Font(RichTextBox.SelectionFont.FontFamily, size, RichTextBox.SelectionFont.Style); } What is the error I know. The program assigns all selected one size and one style. The question is different. How to make the program keep its size and style when assigning new Font() ? Is it really necessary to do everything character by character through a cycle?
PS Also, by the way, it should work when I select the text size, also through the ComboBox .