By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,476 Members | 889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,476 IT Pros & Developers. It's quick & easy.

How do you get a list of Datagrid names?

P: n/a
KC
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.

---
Ken
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"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
Nov 20 '05 #2

P: n/a
KC
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

Nov 20 '05 #3

P: n/a
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


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.