2024年4月8日发(作者:)

用C#编写ActiveX控件(一)

前些日子做一个Web项目,必须自己编写一个ActiveX控件。如今的ActiveX控件大

多是使用VB/C++来开发的,而我对他们并不熟悉,因此考虑使用熟悉的C#编写ActiveX

控件。

首先,建立一个WinForm控件项目HelloWorld,并拖入一个Label控件,文字设为

HelloWorld,如图:

内容如下:

using System;

using tions;

using entModel;

using g;

using ;

using ;

namespace HelloWorld

{

///

/// UserControl1 的摘要说明。

///

public class Demo : ntrol

{

private label1;

///

/// 必需的设计器变量。

///

private ner components = null;

public Demo()

{

// 该调用是 窗体设计器所必需的。

InitializeComponent();

// TODO: 在 InitComponent 调用后添加任何初始化

}

///

/// 清理所有正在使用的资源。

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if( components != null )

e();

}

e( disposing );

}

组件设计器生成的代码