Apply property setting to all controls in Project in Visual Studio

Let's say I have multiple DataGrids throughout my winform application and I want to set the BackColor to ALL of them in Purple in Visual Studio.

What's the fastest way to set a property on multiple NOT elements located in the same shape?

Thanks!

+1


a source to share


3 answers


Since you are asking about changing this at design time and not at runtime, I would search your entire solution for a "new DataGrid" and change them in the designer.cs (or designer.vb) files. Other than that, I cannot think of a faster way other than to write some kind of macro.



+2


a source


There is a property - you can iterate over that list and then iterate over the Controls property of each control recursively, modifying those that match your type. Application.OpenForms



Is this what you are looking for?

+2


a source


Instead of looking for "new DataGrid", why not look for ".BackColor =", which is the string that you will be changing (bearing in mind that other controls have a .BackColor property, so don't just blindly update).

Hope it helps,

Bill

+1


a source







All Articles