Solved

how to access COM components events in c#

Posted on 2006-11-15
3
440 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
ID: 17950289
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
ID: 17955053
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
ID: 17955313
Don't wory about the above comment I've wroked it out

Tanks for your help

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 104
T-SQL:  Sigh---Boy, this is fun.... 12 56
ejb stateless example 2 20
ejb wildfly example 2 20
A short article about problems I had with the new location API and permissions in Marshmallow
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

839 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