Click here to Skip to main content
15,910,224 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey guys
am trying to change fontstyle or textstyle of text(writing) in a rich box
i got some of these font style listed in a combobox (Arial,Cambria,Tahoma)
what i want to do is when you select a textstyle i want the text in the richtextbox to be change according to the selected font in the combobox

i have already tried a few codes but some would not work and some gave me errors

here is the last code i have tried

if (toolStripComboBox2.SelectedItem == @"Tahoma")
richTextBox1.SelectionFont = new FontStyle(richTextBox1.SelectionFont.FontFamily, Tahoma);
Posted

1 solution

SQL
Font font_to_apply = richTextBox1.Font;
            font_to_apply = new Font(new FontFamily(fontNameComboBox.SelectedItem.ToString()), float.Parse(this.fontSizeComboBox.SelectedItem.ToString()));

            richTextBox1.SelectionFont = font_to_apply;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900