Access variable in other form ?

  • Thread starter Thread starter Piet Doms
  • Start date Start date
P

Piet Doms

Hello All,

Very new in C# for CF, How can I access variable in Form1 for use in Form2

My code so far :

Form1

public GPSReader _gpsReader ; // I use the GPSReader from JW Hedgehog

public string _strGPS_Lat ;

public string _strGPS_Long ;

public GPSReader getGPSReader

{

get { return _gpsReader ;}

}



Form2

public GPSReader myGpsReciever;

public void DoSomething(frmMain anotherForm)

{

myGpsReciever = anotherForm.getGPSReader

}



How do I call the DoSomething in Form2 ??

I'm not sure this code is working because I cannot call DoSomething

Anybody ideas or better ways to get this going ?

Thanks,

Piet
 
Piet,

I would consider using a "main" class which loads these two forms. Form 1
could raise an event to the main class with the data you want as an argument
to this event. Then the "main" class would load and call the second form's
method with this data.

Hope that helps

Sai
 
Hello Sai

Do you have an example how to use a main class which loaded my app mainform
and form and that the mainform could raise a event to access variables and
properties of the mainform into form2.

I'm very new in C# for the CF...(I'm a senior delphi programmer)

If you could help me out in this one I will be very thankfull.

Kind regards,

Piet
 
Back
Top