guest31ro Posted May 24, 2003 Posted May 24, 2003 (edited) I have to forms (2 diferent clases) and one object, I need that object in the bougth forms. How do I do that? If I declare that object in the first form, how do I see it in the second? Thanks. Edited May 24, 2003 by guest31ro Quote
sizer Posted May 24, 2003 Posted May 24, 2003 MODULE you can put your object declaration in module ! Public myObject as New Something() Quote Some people are wise and some are other-wise.
guest31ro Posted May 24, 2003 Author Posted May 24, 2003 for exapmle I have something like this: public class Form1:form { ...... static void Main() { Form1 FormN = new Form1(); Application.Run(FormN); } ..... private void top() { FormN.Size = new Size(30;56); } } I would like to use the FormN in a new form but if I declare it outside the main, I can not see it in main, and if I declare it in main I con not see it outside the main. What should I do? Quote
sizer Posted May 24, 2003 Posted May 24, 2003 (edited) you could overload constructor of your "other Forms" and then you can pass FormN as parametar!! Edited May 24, 2003 by sizer Quote Some people are wise and some are other-wise.
guest31ro Posted May 24, 2003 Author Posted May 24, 2003 I have to forms (cass-es) Form A and Form B The problem is that I nedd to modify something from Form B in Form A, and olso I need to modify something form Form A in Form B. What should I do? Any sugestion? Thanks. Quote
APaule Posted May 25, 2003 Posted May 25, 2003 If you declare the variables that hold your forms as public, then you can access them from anywhere in your application. Quote
aewarnick Posted May 30, 2003 Posted May 30, 2003 If FormA created FormB you need to use static variables in FormA for FormB to access them. From FormB you will need to use FormA.YourStaticVariable=10; Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.