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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.