views:

43

answers:

3

Hi,

I new to c# and windows form programming. Here is the problem i am trying to solve.

I have to write an application that uses an multiple instance of an ActiveX control. Therefore, I dragged as many control as necessary to my Form. Now my problem is that i'd like to add some personalised methods to this activeX. The logical solution I thought was to create my own class derived from that aciveX and add some more members and methods to that class so it would work as desired. Now my problem is that the newly generated class doesn't exists as a control that can be inserted into the form.

So How can a class become a control and then inserted into a form ?

A: 

If you look at the Designer.CS file that corresponds to your form, you should see, in the #region Windows Form Designer generated code, the code that was generated when you dragged the ActiveX control onto the form.

This code is similar to what your code needs to look like.

Robert Harvey
A: 

My guess would be that you should wrap this activex into your own control, and add funcionality that lacks into that wrapper.

Pros: you'l have .net control and will be able to extend it and use it anyway you like.

Cons: if you want to access original methods, you'll have to generate pass-through method wrappers.

How: - create a control class - drop activex you have onto it - set activex dock to 'fill' - either set control to public, create get wrapper for it, or create method wrappers you desire - compile that and use it on the form.

Daniel Mošmondor
A: 

You might want to check out this tutorial on creating custom controls. And this from microsoft.

Chris Lively