0
    private void ToolStripButtonBold_CheckedChanged(object sender, EventArgs e)
    {
        Font oldFont;
        Font newFont;

        bool checkState = ((ToolStripButton)sender).Checked;

        //Get the font that is being used in the selected text.
        oldFont = this.richTextBoxText.SelectionFont;

        if (!checkState)
            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();

        this.ToolStripMenuItemBold.CheckedChanged -= new EventHandler(ToolStripMenuItemBold_CheckedChanged);
        this.ToolStripMenuItemBold.Checked = checkState;
        this.ToolStripMenuItemBold.CheckedChanged += new EventHandler(ToolStripMenuItemBold_CheckedChanged);
    }

this one newFont = new Font(oldFont, oldFont.Style & ~FontStyle.Bold); i can't understand ,please tell me ,thank you

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by LizR
0

Well. Debug, watch what happens as you go through the stages.. Especially looking at the newFont.Style property

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.