Hi im trying to loop through only the listviews in a group that i have on my form. Here is the code i am using at the moment:
The problem with this is that if a certain control in the grp.controls list is not a listview then the programme crashes. The same problem is present in looping through the groupboxes on the form however if there are no non-groupbox controls then the loop works. How would i loop through the list of controls and only find the listview boxes?
VB.NET:
'disable all but the processor group to allow the form to be filled in the correct order
For Each grp As GroupBox In Me.Controls
If grp.Name <> "grpProcessors" Then
grp.Enabled = False
For Each lst As ListView In grp.Controls
lst.Items.Clear()
Next
For Each txt As TextBox In grp.Controls
txt.Text = ""
Next
End If
Next
The problem with this is that if a certain control in the grp.controls list is not a listview then the programme crashes. The same problem is present in looping through the groupboxes on the form however if there are no non-groupbox controls then the loop works. How would i loop through the list of controls and only find the listview boxes?