Well I've been having a blast design a thin PPC client for my web application
using mixture xml and webservices.

Pardon my newbie quesiton but should be a easy one.

My questions is I have two forms, one for "Login.cs" and "Main.cs". Because
I'm a web developer, I'm not familiar how to pass a assigned UserID variable
after capturing it in Login and being able to use it Main.cs I tried set/get
and public methods, is the only way inheritence?

Re: HowTo: Assign Global Variable Over 2 Forms by Chris

Chris
Fri Jul 15 14:10:15 CDT 2005

Inheritance won't help you here. Add a ctor to the second form that takes
the value you want to pass as a parameter.

--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate


"Rob G" <RobG@discussions.microsoft.com> wrote in message
news:78E782A4-25AB-4C08-8652-589C30E2CB0D@microsoft.com...
> Well I've been having a blast design a thin PPC client for my web
> application
> using mixture xml and webservices.
>
> Pardon my newbie quesiton but should be a easy one.
>
> My questions is I have two forms, one for "Login.cs" and "Main.cs".
> Because
> I'm a web developer, I'm not familiar how to pass a assigned UserID
> variable
> after capturing it in Login and being able to use it Main.cs I tried
> set/get
> and public methods, is the only way inheritence?
>
>



RE: HowTo: Assign Global Variable Over 2 Forms by MichaelBaltic

MichaelBaltic
Fri Jul 15 14:21:03 CDT 2005

create a class that has an instance of itself as member variable
put the global items you want in this class
make the self reference static
the first time you access it, it will instantiate and become available for
the rest of your application session

/// <summary>
///
/// </summary>
sealed class FormCache : CollectionBase
{

#region [ Member Variables ]
/// <summary>
///
/// </summary>
private System.Collections.ArrayList m_Stack = new ArrayList ( );
/// <summary>
///
/// </summary>
public static readonly FormCache Instance = new FormCache ( );
/// <summary>
///
/// </summary>
private Form m_RootForm = null;
/// <summary>
///
/// </summary>
private bool m_Activation = false;
#endregion

}
--
Direct Email: Michael.Baltic@RemoveCharactersUpTo#NCMC.Com

Staff Consultant II
Enterprise Web Services
Cardinal Solutions Group


"Rob G" wrote:

> Well I've been having a blast design a thin PPC client for my web application
> using mixture xml and webservices.
>
> Pardon my newbie quesiton but should be a easy one.
>
> My questions is I have two forms, one for "Login.cs" and "Main.cs". Because
> I'm a web developer, I'm not familiar how to pass a assigned UserID variable
> after capturing it in Login and being able to use it Main.cs I tried set/get
> and public methods, is the only way inheritence?
>
>

Re: HowTo: Assign Global Variable Over 2 Forms by RobG

RobG
Sun Jul 17 11:24:02 CDT 2005

Chris I like your solution, can you point me to an example or very simple
code sample if handy. I did some searching and could not find example.

"Chris Tacke, eMVP" wrote:

> Inheritance won't help you here. Add a ctor to the second form that takes
> the value you want to pass as a parameter.
>
> --
> Chris Tacke
> Co-founder
> OpenNETCF.org
> Are you using the SDF? Let's do a case study.
> Email us at d c s @ o p e n n e t c f . c o m
> http://www.opennetcf.org/donate
>
>
> "Rob G" <RobG@discussions.microsoft.com> wrote in message
> news:78E782A4-25AB-4C08-8652-589C30E2CB0D@microsoft.com...
> > Well I've been having a blast design a thin PPC client for my web
> > application
> > using mixture xml and webservices.
> >
> > Pardon my newbie quesiton but should be a easy one.
> >
> > My questions is I have two forms, one for "Login.cs" and "Main.cs".
> > Because
> > I'm a web developer, I'm not familiar how to pass a assigned UserID
> > variable
> > after capturing it in Login and being able to use it Main.cs I tried
> > set/get
> > and public methods, is the only way inheritence?
> >
> >
>
>
>

Re: HowTo: Assign Global Variable Over 2 Forms by Chris

Chris
Mon Jul 18 09:24:16 CDT 2005

Here's a simple example that shows 2 ways: via contructor, or via Property:

class Form1 : Form
{
private Form2 m_form2;

public Form1() {...}

void ShowForm2(int myvar)
{
if(m_form2 == null)
{
m_form2 = new Form2(myvar);
}
else
{
m_form2.CustomVar = myvar;
}

m_form2.Show();
}
}

class Form2 : Form
{
private int m_myvar;

public Form2(int myvar)
{
m_myvar = myvar;
}

public int CustomVar
{
set { m_myvar = value; }
}
}


--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate


"Rob G" <RobG@discussions.microsoft.com> wrote in message
news:9604789C-5440-4117-8FA1-C760BA9CF51F@microsoft.com...
> Chris I like your solution, can you point me to an example or very simple
> code sample if handy. I did some searching and could not find example.
>
> "Chris Tacke, eMVP" wrote:
>
>> Inheritance won't help you here. Add a ctor to the second form that
>> takes
>> the value you want to pass as a parameter.
>>
>> --
>> Chris Tacke
>> Co-founder
>> OpenNETCF.org
>> Are you using the SDF? Let's do a case study.
>> Email us at d c s @ o p e n n e t c f . c o m
>> http://www.opennetcf.org/donate
>>
>>
>> "Rob G" <RobG@discussions.microsoft.com> wrote in message
>> news:78E782A4-25AB-4C08-8652-589C30E2CB0D@microsoft.com...
>> > Well I've been having a blast design a thin PPC client for my web
>> > application
>> > using mixture xml and webservices.
>> >
>> > Pardon my newbie quesiton but should be a easy one.
>> >
>> > My questions is I have two forms, one for "Login.cs" and "Main.cs".
>> > Because
>> > I'm a web developer, I'm not familiar how to pass a assigned UserID
>> > variable
>> > after capturing it in Login and being able to use it Main.cs I tried
>> > set/get
>> > and public methods, is the only way inheritence?
>> >
>> >
>>
>>
>>