Good morning, I need to use "if" to find out what the style is on the selected text in a richtextBox.
Here is my code;
string selectedTextTemp = "";
private void richTextBox_message_MouseMove(object sender, MouseEventArgs e)
{
if (!(selectedTextTemp.Equals(richTextBox_message.SelectedText)))
{
if(richTextBox_message.SelectionFont.Style == FontStyle.Underline)
{
pictureBox_underline.BackColor = Color.FromName("PeachPuff");
}
else
{
pictureBox_underline.BackColor = Color.FromName("Linen");
}
}
selectedTextTemp = richTextBox_message.SelectedText;
}
This code works fine, but when the text is in italics or bold and underlined, it doesn't work anymore because I have to put if the text is in bold, and italic and all that makes the code very long.
So it was to know if it was possible to know if the text is underlined without knowing the other styles that are on it.
Thank you
Aucun commentaire:
Enregistrer un commentaire