Visual C#创建和使用ActiveX组件
http://tech.ddvip.com 2006年08月02日 社区交流
本文详细介绍Visual C#创建和使用ActiveX组件

图02:在项目中【添加新项】对话框
9. 把Visual Studio .Net的当前窗口切换到【MyControl.cs(设计)】窗口,并从【工具箱】中的【Windows窗体组件】选项卡中往设计窗体中按顺序拖入下列组件:
一个GroupBox组件,并向此组件中再拖入,
一个TextBox组件和一个Lable组件。
10. 把Visual Studio .Net的当前窗口切换到【MyControl.cs】代码编辑窗口,并用下列代码替换MyControl.cs中的InitializeComponent过程,下列代码是初始化上述加入的组件:
private void InitializeComponent ( )
{
this.groupBox1 = new System.Windows.Forms.GroupBox ( ) ;
this.txtUserText = new System.Windows.Forms.TextBox ( ) ;
this.label1 = new System.Windows.Forms.Label ( ) ;
this.groupBox1.SuspendLayout ( ) ;
this.SuspendLayout ( ) ;
this.groupBox1.Controls.Add ( this.txtUserText ) ;
this.groupBox1.Controls.Add ( this.label1 ) ;
this.groupBox1.Location = new System.Drawing.Point ( 8 , 8 ) ;
this.groupBox1.Name = "groupBox1" ;
this.groupBox1.Size = new System.Drawing.Size ( 272 , 56 ) ;
this.groupBox1.TabIndex = 0 ;
this.groupBox1.TabStop = false ;
this.groupBox1.Text = "Visual Studio .Net创建的Active X组件" ;
this.txtUserText.Enabled = false ;
this.txtUserText.Location = new System.Drawing.Point ( 84 , 20 ) ;
this.txtUserText.Name = "txtUserText" ;
this.txtUserText.Size = new System.Drawing.Size ( 180 , 21 ) ;
this.txtUserText.TabIndex = 1 ;
this.txtUserText.Text = "" ;
this.label1.Location = new System.Drawing.Point ( 8 , 24 ) ;
this.label1.Name = "label1" ;
this.label1.Size = new System.Drawing.Size ( 66 , 16 ) ;
this.label1.TabIndex = 0 ;
this.label1.Text = "输入信息:" ;
this.Controls.Add ( this.groupBox1 ) ;
this.Name = "MyControl" ;
this.Size = new System.Drawing.Size ( 288 , 72 ) ;
this.groupBox1.ResumeLayout ( false ) ;
this.ResumeLayout ( false ) ;
}
来源:天极开发 作者:阿虎 责编:豆豆技术应用