ProgramadoraR Posted May 29, 2012 at 03:03 PM Report #458919 Posted May 29, 2012 at 03:03 PM Boas, preciso de uma ajuda Alguém me pode ajudar dizendo como posso automatizar o código quando tenho este código assim (muito repetitivo): Box40.Visible = false; Box41.Visible = false; Box39.Visible = false; Box42.Visible = false; Box43.Visible = false; Box44.Visible = false; Box45.Visible = false; Box46.Visible = false;
Gonka Posted May 29, 2012 at 03:12 PM Report #458922 Posted May 29, 2012 at 03:12 PM foreach (Control x in this.Controls) { if (x is oTeuControlo) { ((oTeuControlo)x).Visible = false; } }
ProgramadoraR Posted May 29, 2012 at 03:49 PM Author Report #458930 Posted May 29, 2012 at 03:49 PM (edited) Onde escreveste "oTeuControlo" meto o que? e onde escreveste "Control" meto o que? e o x? eu tenho varios a dizer box.visible = false; desculpa mas nao percebi muito bem Edited May 29, 2012 at 03:50 PM by ProgramadoraR
Gonka Posted May 29, 2012 at 03:50 PM Report #458931 Posted May 29, 2012 at 03:50 PM O tipo do controlo que queres aceder.. Não sei o que é o teu Box, mas se for uma textBox(por exemplo) metes TextBox.
ProgramadoraR Posted May 29, 2012 at 03:57 PM Author Report #458938 Posted May 29, 2012 at 03:57 PM (edited) ja percebi, obrigada 😄 Edited May 29, 2012 at 03:59 PM by ProgramadoraR
petvetbr Posted May 29, 2012 at 04:09 PM Report #458941 Posted May 29, 2012 at 04:09 PM acho que já te responderam, mas é só fazer um loop (for, foreach) no form/tela que contém os controles e ir modificando eles. Se você colocar a interface que está usando (winforms, WPF, web) fica mais fácil dizer como o código deve ser. Fernando Lage Bastos - MCP/MCTS/MCPD
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now