Question

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!

Was it helpful?

Solution

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.

OTHER TIPS

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?

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top