I have a rich text box and in the formatting toolbar (that sticks to its upper border) I have a ComboBox that displays the standard Font sizes. Just like it is in MS Word or Excel.
The user after selecting text will click a size. How do I achieve this?
I know how to handle this when the selected text is written in a single font. I put the following code in the SelectedIndexChanged event of the combobox.
Expand|Select|Wrap|Line Numbers
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- Font font=new Font(richTextBox1.SelectionFont.FontFamily.ToString(),Convert.ToInt16 (comboBox1.Text),richTextBox1.SelectionFont.Style);
- richTextBox1.SelectionFont = font;
- }
Expand|Select|Wrap|Line Numbers
- rtb.SelectionFont.FontFamily
Expand|Select|Wrap|Line Numbers
- rtb.SelectionFont
I cannot use a font dialogue box or anything that would force me change the UI.
Any suggestion would help.
Regards,
Sid