0

I'm using verion 3.5 of the .NET framework

I have a form with a number of controls including text boxes.

All my text boxes are named in the style txb_name, can I search for controls with txb in their name? The following code doesn't work:

For Each tb As TextBox In Me.Controls.Find("txb", True)
'do something with tb
next

I tried using OfType but that gives the error: 'OfType is not a member of System.Windows.Forms.Control.ControlCollection'

any ideas?

TIA

Hx

P.S. I wanted to discuss this in relation to a similar post, but apparently that isn't allowed on this forum.

Edited by __avd: Corrected [code] tags.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by HappyMe
0

I've sorted it out:

For Each c As Control In Me.MyPanel.Controls
    If c.Name.StartsWith("txb_") Then
         
'use textboxes here

Next

Maybe not the most elegant solution, but it works!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.