Hi,
Use recursion.
CheckForGrid(Me.Controls)
Private Sub CheckForGrid(ByVal ctrls As Control.ControlCollection)
For Each ctrl As Control In ctrls
If TypeOf ctrl Is DataGrid Then
Trace.WriteLine(DirectCast(ctrl, DataGrid).Name)
End If
CheckForGrid(ctrl.Controls)
Next
End Sub
Ken
---------------------------------
"KC" <yo*@dontneed.this> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Thank you. That helped a lot. But that example I've found assumes all my
datagrids are in the top 'Me' form. There's no easy way to get ALL the
controls in my app is there? I've got my stuff in panels in tabcontrols in
whatever....
Or will I just have to point it to the right subcontrols?
Ken
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:OU**************@TK2MSFTNGP10.phx.gbl...
"KC" <yo*@dontneed.this> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> How can I get a list of DataGrids used in my application? I could
obviously > do this manually at design time, but I don't want to have to update the
> list.
For Each c As Control In Controls
If TypeOf c Is DataGrid Then
' Add the name to your array
End If
Next