Hi everyone,
I am trying to find a way to highlight the active button appearance on my winform.Here I have a simple Text Editor with a richTextBox and a btnBold button located at ToolStrip which can change the font Style to be bold or not.Now I want to change the appearance of the btnBold if already clicked and release it to normal when it clicked again then user will be notice that if the btnBold, btnUnderline, and btnItalic has been set or not?

I really appreciate your time about this

Recommended Answers

All 4 Replies

Thanks Steve,
However,as I mentioned already I am using the btnBold button located at ToolStrip as standard style of all text editors style.
using the method which you offered from the MSDN library as:

ControlPaint.DrawButton(System.Drawing.Graphics.FromHwnd(toolStripButton1.Handle), 0, 0, toolStripButton1.Width, toolStripButton1.Height,ButtonState.Pushed);

generates an error as:
Error 1 'System.Windows.Forms.ToolStripButton' does not contain a definition for 'Handle' and no extension method 'Handle' accepting a first argument of type 'System.Windows.Forms.ToolStripButton' could be found (are you missing a using directive or an assembly reference?)

Can you please let me know how I can fix this?Is there any other method for example we can force the btnBold to keep Highlithed until next click?

Thanks

on click of btn bold make btn font style bold

private void btnbold_Click(object sender, EventArgs e)
        {
            if (btnbold.Checked)
            {
                btnbold.Checked = false;
                btnbold.CheckState = CheckState.Unchecked;
                btnbold.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
            }
            else {
                btnbold.Checked = true;
                btnbold.CheckState = CheckState.Checked;
                btnbold.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
            }
        }
commented: Perfect solution +3

Hi pritesh2010,
Thanks for your perfect solution.This is exactly what I was looking for.

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.