James,

This may work but it would be incredibly slow.  Better to use a
reference to access the control you want directly. eg something like
either Ben's or my previous post.

David

"If we can hit that bullseye, the rest of the dominoes
 will fall like a house of cards... checkmate!"
 -Zapp Brannigan, Futurama


On Tue, Jul 26, 2011 at 16:07, James Chapman-Smith
<[email protected]> wrote:
> I assume you wanted VB.NET. If not, I can provide a better answer in C# if
> you need it.
>
>
>
> Try this:
>
>
>
>         For Each button In (From x In Me.GetAllControls(Me).OfType(Of
> Button)() _
>
>             Where x.Name = "Button" & n _
>
>             Select x)
>
>             button.Text = t
>
>         Next
>
>
>
> You need to define this function:
>
>
>
>     Private Function GetAllControls(ByVal control As Control) As
> IEnumerable(Of Control)
>
>         Dim r = New List(Of Control)
>
>         r.Add(control)
>
>         For Each c In control.Controls
>
>             r.AddRange(GetAllControls(c))
>
>         Next
>
>         Return r
>
>     End Function
>
>
>

Reply via email to