Solved

how to access COM components events in c#

Posted on 2006-11-15
3
430 Views
Last Modified: 2013-11-25
I am writing a class library that uses some third party COM components as well as serial comms

I need to know how to access the events associated with these controls - for example:

I have successfully set up a serial comms object using by referencing Microsoft’s comm control 6 in my .net project i.e

 MSCommLib.MSComm port = new MSCommLib.MSComm();

I can then successfully open close the port and set all the relevant properties

eg

port.CommPort = 1;
port.PortOpen = true;

etc..

My problem is how do I access the port.OnComm() event. I have exactly the same problem with some third party controls that work with a specific piece of hardware  I can set the properties but I'm not sure how to get at the events.

Any help would be apreciated.


Regards
0
Comment
Question by:Vitech
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
SCDMETA earned 400 total points
Comment Utility
If you start typing the following, Visual Studio will start prompting you through the rest:

port.OnComm += new MSCommLib.DMSCommEvents_OnCommEventHandler(port_OnComm);

private void port_OnComm()
{

}
0
 
LVL 1

Author Comment

by:Vitech
Comment Utility
Thanks for that, but there’s one more thing. The above codes works but the new Port_OnComm routine is created as a method for my class. I really need it to create an event for my class so that in the program that uses the library i can use the following code example

MyClass.port_OnComm += new EventHandler(MyClass_port_OnComm)


Currently this fails with the following error

Cannot assign to port.OnComm' because it is a 'method group'      

Thanks
 
0
 
LVL 1

Author Comment

by:Vitech
Comment Utility
Don't wory about the above comment I've wroked it out

Tanks for your help

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now