How to add a COM user control to a form

J

Janos

Hi,

I have a COM dll written in C#, I compiled it from its source as .Net2
in VS2008.

It is a User control derived from System.Windows.Forms.UserControl

I compile it as a class library, with COM Interop, VS2008 creates
beutifully dll and tlb for that.

To be able to "run", test an ddebug it: I added a Windows Form
Project, which will "call" this usercontrol under the same solution.
(Just by Add, New Project, Windows Forms Application. The IDE created
a beautiful empty form.). I added a project reference to the COM
control above (IDE has not allowed to add it as a COM reference.)

How do I add, (or embed) the earlier COM user control into that
beutiful empty Form1?

And: How do I handle in the Form1 the COM ButtonClicked() event,
which is an
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IContainerEvents

Any hints appreciated.

Thanks,
Janos
 
J

Janos

OK,

found it.

In (my beautiful empty) Form1 after the
InitializeComponent();
just create an instance of the COM control (ccontrl for ex)
and set
ccntrl.Parent = this;

Now up to the com event catching in Form1

Janos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top