private void buttonBold_Click(object sender, EventArgs e)
{
Font oldFont;
Font newFont; // Get the font that is being used in the selected text
oldFont = this.richTextBoxText.SelectionFont; // If the font is using bold style now, we should remove the
// Formatting
if (oldFont.Bold)
newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Bold);
else
newFont = new Font(oldFont, oldFont.Style | FontStyle.Bold);
// Insert the new font and return focus to the RichTextBox
this.richTextBoxText.SelectionFont = newFont;
this.richTextBoxText.Focus();
}
其中oldFont.Style & ~FontStyle.Bold中的& ~是什么意思啊?谢谢了!
{
Font oldFont;
Font newFont; // Get the font that is being used in the selected text
oldFont = this.richTextBoxText.SelectionFont; // If the font is using bold style now, we should remove the
// Formatting
if (oldFont.Bold)
newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Bold);
else
newFont = new Font(oldFont, oldFont.Style | FontStyle.Bold);
// Insert the new font and return focus to the RichTextBox
this.richTextBoxText.SelectionFont = newFont;
this.richTextBoxText.Focus();
}
其中oldFont.Style & ~FontStyle.Bold中的& ~是什么意思啊?谢谢了!
style |= FontStyle.Bold;
style |= FontStyle.Italic;
去掉某一种:
style-=FontStyle.Bold;
FontStyle fsStyle = (FontStyle)Enum.Parse(typeof(FontStyle), sContentFontStyle);FontStyle fsStyle = (FontStyle)Enum.Parse(typeof(FontStyle), "Bold,Italic,Underline,Strikeout");