教程集 www.jiaochengji.com
教程集 >  操作系统  >  windows  >  正文 转载:用Visual C#动态生成组件,请看!(三)

转载:用Visual C#动态生成组件,请看!(三)

发布时间:2019-12-16   编辑:jiaochengji.com
教程集为您提供转载:用Visual C#动态生成组件,请看!(三)等资源,欢迎您收藏本站,我们将为您提供最新的转载:用Visual C#动态生成组件,请看!(三)资源
下面是实现上面结果的程序源代码:
using System ;
using System.Drawing ;
using System.Collections ;
using System.ComponentModel ;
using System.Windows.Forms ;
using System.Data ;
namespace DynamicControls
{
public class Form1 : Form
{
private Button btnAdd ;
private System.ComponentModel.Container components = null ;
private Button txtAdd ;
//给产生的按钮定义一个数量计算器
private int counter ;
//给产生的按钮定义相对位置的纵坐标
private int locY ;
//给产生的文本框定义一个数量计算器
private int counter01 ;
//给产生的文本框定义相对位置的纵坐标
private int locY1 ;
public Form1 ( )
{
InitializeComponent ( ) ;
//初始化产生的按钮何文本框位置的纵坐标
locY = this.btnAdd.Location.Y ;
locY1 = this.txtAdd.Location.Y ;
}
//清除在程序中使用到的资源
protected override void Dispose ( bool disposing )
{
if ( disposing )
{
if ( components != null )
{
components.Dispose ( ) ;
}
}
base.Dispose ( disposing ) ;
}
private void InitializeComponent ( )
{
this.btnAdd = new Button ( ) ;
this.txtAdd = new Button ( ) ;
this.SuspendLayout ( ) ;
this.btnAdd.FlatStyle = FlatStyle.Popup ;
this.btnAdd.Location = new System.Drawing.Point ( 8 , 16 ) ;
this.btnAdd.Name = "btnAdd" ;
this.btnAdd.TabIndex = 0 ;
this.btnAdd.Text = "生成按钮!" ;
this.btnAdd.Click = new System.EventHandler ( this.btnAdd_Click ) ;
this.txtAdd.FlatStyle = FlatStyle.Popup ;

您可能感兴趣的文章:
转载:用Visual C#动态生成组件,请看!(一)
转载:用Visual C#动态生成组件,请看!(二)
转载:用Visual C#动态生成组件,请看!(三)
用Visual C#动态生成组件(转自中国在线)
用Visual InterDev规划站点
ASP.NET 入门的五个步骤
浅谈PHP组件、框架以及Composer
架构、构件、组件、框架、中间件的区别
用托管C 编写Windows服务
常用的 ASP ActiveX 组件

[关闭]
~ ~