Begginer - WinForm programming
Please could yu assist me with the way for a button in one form to open another form and set its visibility to false. i am a beginer
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Piotr JustynaPosted Nov 27, 2009, 8:18 AM
Form2 secondForm = new Form2();
secondForm.Show();
secondForm.Hide();
But this makes little sense. Depending on what you're going to use the second form for I'd advise you to just create the second form and not show it until it's needed (just skip methods 'Show' and 'Hide').
Tell me if this was helpful please.
Cheers!
EDIT:
I've read your question again and I think you could ask about something different: how to show a form and then hide the button. There's as solution for that too :) Just paste this code in the same method as previous:
Form2 secondForm = new Form2();
secondForm.Show();
(sender as Button).Visible = false;
I hope this helps :)