?
Solved

how to access COM components events in c#

Posted on 2006-11-15
3
Medium Priority
?
457 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 1600 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

A short article about problems I had with the new location API and permissions in Marshmallow
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 …
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

762 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