I am in a bit of a pickle. Usually I am a PHP dev but for this role I am a C# developer. Yippee.
The project I am taking over has a very big deficiency inside, which is that it is not scale-able. Everything is hard coded inside and meant for one specific item. C# is new to me, and I am not sure where to look.
Current state of code is like so:
SomePage.Designer.cs:
private System.Windows.Forms.Label CompLbl1;
private System.Windows.Forms.Label CompLbl2;
private System.Windows.Forms.Label CompLbl3;
...
private System.Windows.Forms.Label CompLbl14;
private System.Windows.Forms.Label CompLbl15;
private System.Windows.Forms.CheckBox CompChkBx1;
private System.Windows.Forms.CheckBox CompChkBx2;
private System.Windows.Forms.CheckBox CompChkBx3;
...
private System.Windows.Forms.CheckBox CompChkBx14;
private System.Windows.Forms.CheckBox CompChkBx15;
private System.Windows.Forms.TextBox CompScanBox1;
private System.Windows.Forms.TextBox CompScanBox2;
private System.Windows.Forms.TextBox CompScanBox3;
...
private System.Windows.Forms.TextBox CompScanBox14;
private System.Windows.Forms.TextBox CompScanBox15;
SomePage.cs
private void CompChkBx1_CheckedChanged(object sender, EventArgs e)
{
if (Rwk1 == true)
{
Rwk1 = false;
CompScanBox1.Visible = false;
}
else
{
Rwk1 = true;
CompScanBox1.Visible = true;
}
// Console.WriteLine("Rework = " + Rwk1.ToString());
}
... all the way
private void CompChkBx15_CheckedChanged(object sender, EventArgs e){}
All of the above is hard coded.
This will break when implemented on a larger scale, say 20 components. Is there a way to make this a bit more dynamic? I'd appreciate a point in the right direction