How to set focus on dynamically created controls in VB.Net?

Lukas Wolfe

New member
I have a program where I dynamically create some Textboxes within a Panel on my form using this code

Panel1.Controls.AddRange(New System.Windows.Forms.Control() {TextBoxes(num - 1)})

These textboxes are automatically labeled Layer1, Layer2 etc etc.. Everything works fine.

I also have a listbox that contains the names of these dynamically created "Layers". What I want to do is when I click on the name in the listbox I want to "select" (or set the focus) on that particular dynamic control.. but I don't know how to reference it, as it's dynamic lol.

Any help would be MUCH appreciated, thanks!
 
Back
Top