Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use for loop for all control in form to do someth
Message
De
12/10/2011 07:12:07
 
 
À
12/10/2011 04:41:11
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01526108
Message ID:
01526124
Vues:
52
J'aime (1)
>Hi all,
> I use vb.net. Anyone know how do use for loop all control in form to do something?
>Thank you ~~~

There's a good example here :http://stackoverflow.com/questions/1467964/how-do-i-iterate-controls-in-a-windows-form-app
VB equivalent would be:
<System.Runtime.CompilerServices.Extension> _
Public Shared Function FindChildrenOfType(Of TChildType As Control)(currentControl As Control) As List(Of TChildType)
	Dim childList = New List(Of TChildType)()
	For Each childControl As Control In currentControl.Controls
		If TypeOf childControl Is TChildType Then
			childList.Add(DirectCast(childControl, TChildType))
		End If
		childList.AddRange(childControl.FindChildrenOfType(Of TChildType)())
	Next
	Return childList
End Function
This has the added benefit of allowing you to filter by control type if required and also to begin drilling down from any control rather than just the form....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform