Reputation: 12216
Lets say I have multiple DataGrids throughout my winform app and I want to set the BackColor on ALL of them to Purple in Visual Studio.
What is the fastest way of setting a Property for multiple items NOT located on the same Form?
Thanks!
Upvotes: 2
Views: 168
Reputation: 644
Rather than search for "new DataGrid", why not search for ".BackColor =" which is the line you'll be changing (keeping in mind that other controls have a .BackColor property so don't just do a blind update).
Hope this helps,
Bill
Upvotes: 1
Reputation: 12503
Since you're asking about changing this at design time and not runtime, I would do a search on your whole solution for "new DataGrid" and change them in the designer.cs (or designer.vb) files. Other than that, I can't think of a quicker way other than maybe writing some sort of macro.
Upvotes: 2
Reputation: 4590
There is an Application.OpenForms
property - you can loop over that list, then loop over the Controls property of each control recursively, modding those that match your type.
Is that the kind of thing you're looking for?
Upvotes: 2