I am very new to c# and visual studio.
I am using c# with Visual studio. I want to create a method that lops through a number of textboxes and labels and set their visible control to "True."
This is the code I have come up with so far, but it does not work.
public static void showFields(params string[] values)
{
foreach (var value in values)
{
value.Visible = true;
}
}
Any help would be greatly appreciated.
2
Answers
Code should be similar to this. You may have nested controls. In this case, you create a recursive method
Your form is also
control
If you already have a list of needed controls in the form of array –
Control[] values
, you can use LINQYou are on the right path, just need to replace
string
withControl
, by the way,string
does not have theVisible
property.