Change Multiple Controls Properties via code

My form has multiple buttons (20 of them), when one is clicked it change the backcolor and forecolor. I would like to change the color of all the buttons at once.

Is there an easier way to do this other than

Button1.BackColor = ...

Button2.Backcolor = ...

Button3.Backcolor = ...



Answer this question

Change Multiple Controls Properties via code

  • monk3yatthekeyboard

    You can loop through the controls collection on a form searching for a controls of a specific type.

    For each ctrl as control in Me.Controls
    if typeof(ctrl) is Button then
    Ctype(ctrl, Button).BackColor = ..
    end if
    Next


  • Change Multiple Controls Properties via code