The wish to pass a value from a (child) class to a (parent) form class!

The wish to pass a value from a (child) class to a (parent) form class!

Post by H_ston » Wed, 02 Jul 2008 02:29:37


I have a MainForm class and a second class which initializes an
instance of a second class which I call CommunicationManager.

This is just a simplified representation of the MainForm class:

partial class MainForm : Form
{
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}

// Public accessor
public string textToDisplayBox
{
set { this.textBox4.Text = value; }
}

// CommunicationManager
CommunicationManager comm = new CommunicationManager();

}

The CommunicationManager class has a simple function, i.e. to collect
in a string the output from the comport...

My troubles stem from the fact that I am unable to reference back to
the form which second class is initiated.

Do you have any suggestions on how to achieve this?

Best regards,
H
 
 
 

The wish to pass a value from a (child) class to a (parent) form class!

Post by .NET/ C# » Wed, 02 Jul 2008 04:12:59


Hi,

It's not very clear from your post where is your problem.
You can pass to the contructor of CommunicationManager a reference to
your form
CommunicationManager comm = new CommunicationManager( this);