My program consist of two classes: Form1 (windows form with textbox) and SerialCommunication (class for serial communication).
When data occurs on COM port DateRecievedHandeler store the message to indata.

public ref class SerialCommunication
     static SerialPort^ mySerialPort;

     static String^ indata;
     static void OpenPort();
     static void Close();
     static void DataReceivedHandler(Object^ sender, SerialDataReceivedEventArgs^ e);  

In Form1 are included SerialCommunication.h and I have initialized object from SerialCommunication.

How to write method in class Form1 that will print indata to textbox from Form1 after DataRecievedHandler occurs.

Program is written in Visual C++ 2008 CLI aplication.

Recommended Answers

All 3 Replies

String^ indata is declared as public so it will be accessible from Form1
as long as your SerialCommunication class is included in you Form1 class.

I know that, but I don't know how to write function that will read indata when DataReceivedHandler occurs
(DataReceivedHandler rewrite indata)

Other solution that I don't know how to make is that I somehow override method DataRecivedHandler (from SerialCommunication ) in class Form1 so that I can write to textbox from derivated DataRecivedHandler

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.