PC Review


Reply
Thread Tools Rate Thread

Access variable in other form ?

 
 
Piet Doms
Guest
Posts: n/a
 
      7th Sep 2004
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












 
Reply With Quote
 
 
 
 
Sai
Guest
Posts: n/a
 
      7th Sep 2004
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

"Piet Doms" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>
>
>
>
>
>
>
>
>
>



 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      9th Sep 2004
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



"Sai" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> 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
>
> "Piet Doms" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access variable from form and module? =?Utf-8?B?cGFya2luX20=?= Microsoft Excel Programming 1 8th Aug 2007 03:32 PM
Access to a variable in the parent form Ludwig Microsoft Access 3 11th Dec 2005 03:12 PM
How to access a variable from mdi form to child form Gomathi Microsoft Dot NET Framework Forms 1 22nd Sep 2005 01:27 PM
Access to a control in a form through a variable... Nicola Microsoft Dot NET Framework Forms 11 15th Jan 2004 10:34 AM
passing variable into word from access form Steven Scaife Microsoft Access Form Coding 0 8th Jan 2004 10:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:41 PM.