In this code I have several elements like text box and buttons, and on depend the case, some are visible and some are not, like this (there are more elements):
txtTipCOP.Visible = true;
lblIngreseCantidad.Visible = true;
lblEquivale.Visible = true;
txtTCDolar.Visible = false;
txtTCEuro.Visible = false;
btnCantidadInicio.Visible = false;
btnEquivaleInicio.Visible = false;
txtCantidad.Visible = false;
txtEquivalen.Visible = false;
I want to optimize the code, but I don't know how to control several Visible properties with 1 true, is this possible?
Thank you for your time.
I am changing every Visible property individually but I think it's not the optimal way?
If you're looking to set all these controls to Visible = true, you could create a foreach loop. Modify the following to your needs.
However in terms of performance, it will be negligible because its performing the same operation if you set them all individually. Personally I would go with ever is more maintainable.