You have not specified if this is a Windows form or Web application.
Still, the method is usually the same: Find the immediate container of
the required labels (or create one to make the search more specific)
and loop through the Child controls collection checking each one for
type constraints and if the type matches label, set the required
properties. Your loop can be a For-Each loop.
For instance, (typed in here, watch for syntax)
---
For each c as Control in Panel1.Controls
If TypeOf (c) is Label then
Dim l as Label = DirectCast(c, Label)
l.Font = New Font("Calibri", 12.0F)
End If
Next
---
Note that I have placed all the label controls to be iterated over in
a panel, so as to minimize iteration over irrelevant controls.
On May 5, 9:18 pm, Newton <[email protected]> wrote:
> Suppose I have say 20 labels in a form.
> Is there a way, using code, to change font, fontsize, etc in ALL of
> them at once, rather than with 20 lines of code for each attribute
> being changed?
>
> I'm looking for a solution like a For ..In.. Next loop to cycle thru
> all labels in my form.
>
> Thank you