Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Form1 has an another form (FormA) loaded inside a panel. What I would to do is have FormA is to change the visibility of a panel from false to true on Form1.

What I have tried:

Here is what I have tried to do in FormA but get the red marks on the pnlTools when trying to change the visibility from false to true. What am I doing wrong?

C#
Form1 frmx = new Form1();
frmx.pnlTools.visible=true;
Posted
Updated 3-Jun-21 10:57am
v2

 
Share this answer
 
It shouldn't. EVER. That will hard-code the two forms together where one could not be used without the other.

Your code is creating another instance of Form1. It will NOT affect the existing Form1 at all.

What your FormA code should be doing is exposing an event that Form1 can subscribe to. This will allow FormA to notify its subscribers that something needs to be done. That leaves it up to Form1, the subscriber, to decide what to do when the event is raised, like setting the visibility property of its own panel control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900