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
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Piotr Justyna70 reputationPosted Nov 27, 2009, 3:18 AM EST
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 :)