I'm continuing to work on a few VSTO's and I was wondering if there was a way to refer to all the datagridviews in a class at once. I can't seem to figure out what the container should be, and I can't seem to add them to arrays/other containers?
The psudo code for what I'm tring to do would be something like:
For Each datagridview in Globals.MyUserControl
'change some datagridview property ie:
datagridview1.ReadOnly = True
Next
I would be hapy in C# or VB.net, or really any explanation of if this can or can't be done. At the moment I'm manually setting it for all the different datagridviews, as that number grows, I would like a way to hit them all at once.
Still trying to work on the solutions below, another way I've tried this that doesn't work:
For Each ctl In Me.Controls
If TypeOf ctl Is DataGridView Then
ctl.ReadOnly = True
ctl.AllowUserToDeleteRows = False
End If
Next
But I don't know why that doesn't work.