Solved

how to access COM components events in c#

Posted on 2006-11-15
3
456 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Introduction to Processes

724 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