开发者

Transforming a c# class into a visual control

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

I have to write an application that 开发者_如何学Pythonuses 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 ?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜