Click here to Skip to main content
15,901,853 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two windows forms in one application as Form1 & Form2. My problem is I couldn’t “visible true” a textbox using Form2. Please see below my code and let me know what is wrong? In the correction
XML
In the correction I want to run a function/method in Form1 by button click in Form2, so I think it will work well.

Form1:
        internal void VisibleFalse()
        {
            textBox1.Visible = true;
        }

Form2:
        private void button1_Click(object sender, EventArgs e)
        {
            Form1 frm22 = new Form1();
            frm22.VisibleFalse();
        }
Posted

1 solution

you are accessing a new instance of type Form1, which never is shown...i think you need to pass an instance of Form1 to the instance of Form2 in order achieve your goal!
 
Share this answer
 
Comments
abdulsafran 28-Nov-12 5:34am    
Hi Earloc, thanks for your quick response, could you please provide sample code for that?
earloc 28-Nov-12 5:53am    
sorry, but this is such a basic concept...i think you should read about classes (types) and instances. once you have done that, you will be able to solve your issue by yourself! (hint: you should pass an existing instance of Form1 to a new instance of Form2 using either a constructor or a property...)
if i misunderstood your question, please dont hesitate refining your question to a more specific problem.
http://en.wikipedia.org/wiki/Class_(computer_programming)

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