I have a richtextbox and I would like to make it work like WordPad. My problem is that, for example, if I type "123" using the Calibri font, and then "456" using the Arial font and I want to change the size of 2345 it won't let me to do it because they have two different font types. This is where I have the problem:
private void combo_sizes_TextChanged(object sender, EventArgs e)
{
if (rtb.SelectionFont == null)
{
rtb.SelectionFont = new Font(combo_fonts.Text, Convert.ToInt16(combo_sizes.Text));
}
rtb.SelectionFont = new Font(rtb.SelectionFont.FontFamily, Convert.ToInt16(combo_sizes.Text));
}
I know tha when the selected text in the rtb contains multiple fonts the SelectionFont equals to null, so in that case I have made it to get the selected text's size and font from two comboboxes, but I would like to change the size without losing its original font. Is there a solution?
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…