Question

I try to make the flashing effect on the ToolStripButton. By using Select() method, I can give it the mouse hover effect but I don't know how to return it to the normal state.

Edit: I solved this by making a dummy ToolStripButton on the same ToolStip and changed its size to 0,0.

    bool blink = false;

    void timer_Tick(object sender, EventArgs e)
    {
        blink = !blink;
        if (blink)
        {
            button1.Select();
        }
        else
        {
            dummyButton.Select();
        }
    }
Was it helpful?

Solution 2

Please see the solution from my original post.

OTHER TIPS

Instead of calling the Select method, you could just change the backcolor:

    bool blink = false
    Color originalColor;

    private void Form1_Load(object sender, EventArgs e)
    {
        originalColor = Button1.BackColor;
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        blink = !blink;
        if (blink)
        {
            Button1.BackColor = Color.Aqua;
        }
        else
        {
            Button1.BackColor = originalColor;
        }
    }   

Try using the Paint-Event:

private void ToolStripSplitButton_Paint(object sender, PaintEventArgs e)
{
    VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.ToolBar.SplitButton.Checked);
    Rectangle rectangle1 = new Rectangle(0, 0, 21, 22);
    renderer.DrawBackground(e.Graphics, rectangle1);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top