found the following code: Alle Controls einer Form auf Readonly setzen
But how have my Control.ControlCollection look like that I can use this method? I tried the following but it is not working:
Control[] ControlCollection = new Control[] { textbox1 };
Change the parameter type to
IEnumerable<Control> controls
You can also provide an extension method to convert
ControlCollection
toIEnumerable<Control>
:So if you want to use your
SetReadOnly
method withControlCollection
: