Creating and Editing Dynamic Objects

1

Greetings galera.

I have a "problem" and wanted some ideas on how I can solve it.

My goal is to make a selection "animation" on several Buttons, so that when one of the Buttons is clicked, a Panel will be created on it (and, in case another Button is already selected, it removes the Panel of the same).

I'll be more specific. Suppose there is a list of buttons numbered 1 to 3, correct? The first Button to be clicked will be Button 1, so a Colored Panel will be created on it indicating the selection of it. After that, Button 3 is clicked, so that the Panel created on Button 1 is removed and a new one is created on Button 3.

That's where my doubt is. I have a dynamic class for creating the Panel on the selected Button, but I do not know how to perform this "switch positions" made when another Button is selected.

Follow the class content:

public class an
{
    public static void a(Button sender)
    {
        Panel p = new Panel();
        p.BackColor = Color.FromArgb(32, 184, 251);
        p.Dock = DockStyle.Right;
        p.Name = "p";
        p.Size = new Size(8, sender.Height);
        sender.Controls.Add(p);
        sender.BackColor = Color.FromArgb(40, 40, 40);
    }
}

The code works fine, follow a link with images.

link

Notice that when you click, the selection of the Button is made with the change of the background color and the creation of a Panel in blue color. So I would like to adapt my code to "counter-selection" (I do not think this term exists, hahaha) from the other Buttons.

So, I'm waiting for answers!

Excuse me if I was not clear on something.

    
asked by anonymous 08.04.2016 / 21:01

0 answers