.net - How can I change the ForeColor of all labels on a form? -
is possible change forecolor
of labels on form @ runtime, including form yet called? labels have same color throughout app.
you need loop through of form's controls looking labels. controls can have child controls want recursively:
private sub updatelabelfg(byval controls controlcollection, byval fgcolor color) if controls nothing return each c control in controls if typeof c label directcast(c, label).forecolor = fgcolor if c.haschildren updatelabelfg(c.controls, fgcolor) next end sub private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load updatelabelfg(me.controls, color.red) end sub
Comments
Post a Comment