pippyn

Here's the scenario:

Main Form - in the Load function I instansiate Communicationclass. I also have a button which fires up Sub Form.

Communication class keeps track of the server IP, the warehouse number and the listener port. It has getter/setter functions.

Sub Form - needs to display the server IP and allow user to change the warehouse and port.

Problem is, once the load of Main form is completed, the instance of Communication is gone, gone, gone. So, how do I get it to stick around till I'm done, and how do I make it available to sub Forms

Thanks.


Re: .NET Compact Framework share common data between forms

Ilya Tumanov

Keep the instance or copy data from one form to another or create class to hold the data in and share one instance of that class with all forms or use static variable(s) in one of the forms. For example:

public class DataHolder

{

public int DataOne;

public string DataTwo;

¡­

}

class Form1 :¡­

{

public static DataHolder = new DataHolder();

¡­

{

if (Form1.DataHolder.DataOne == 10)

{

}

}

}

class Form2 : ..

{

¡­

{

Form1.DataHolder.DataOne = 10;

}

}






Re: .NET Compact Framework share common data between forms

pippyn

got it, thanks!!