The VS designer is a wonderful tool to use and saves you lots of time.
One drawback though. If you have a lot of the same controls and you want to change some properties of it at runtime, you got some coding to do.
Say you want to change the BackColor of 50 buttons on your form, you could do something like this:
Button1.BackColor = newColor;
Button2.BackColor = newColor;
Button50.BackColor = newColor;
With some copy and paste, this is doable, but I don’t like it.
You know you can index the Controls collection, but you don’t know how the designer has made up this Controls collection(it may contain lots of different controls), see a designer.cs file for that. You also don’t know which control is at which index.
A solution is: leave the designer for what it is and “design everything yourself”, put all your buttons in a list so you got total control(he!) over what is to be done at runtime.
C# is a wonderful language! Another approach is to use the is keyword!
Is returns a Boolean so you can use it in an if statement to check which control you have at hand.
See the code snippet how I used this to set the text of a Label in a bunch of Panels in a TabPage of a Form.