Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A simple C# question I hope! Add additional properties to Buttons

hi on a windows form (not WPF) I dynamically create buttons on a flowlayout and I would like to add some properties to them simply to store other values (int and string) with the buttons for latter use.

            Button bn = new Button();
            bn.Text = "mybutton";
            bn.Name = "mybutton";
            toolTip1.SetToolTip(bn, "some tip");
            bn.Location = new Point(200, 200);
            bn.Size = new Size(110, 30);
            bn.BackColor = SystemColors.Control;
            bn.Show();
            flowLayoutPanel1.Controls.Add(bn);

I have about 6 values I would like to store with each button as it is different for each button..

Can this be done?

like image 653
Adrian Avatar asked Oct 27 '10 17:10

Adrian


1 Answers

For non-strongly-typed information, you can possibly use the Tag property. Otherwise, I think you'd have to subclass.

like image 80
Jason Avatar answered Oct 24 '22 19:10

Jason