protected void button1_click(object sender, EventArgs e){
CheckBox cb=new CheckBox();
cb.ID = "check" ;
Container.Controls.Add(cb);
check.Text=textbox.text ;
}
protected void button2_click(object sender, EventArgs e){
this.lable.text=check.text;
}
using System.Windows.Forms;
/*
* Created by SharpDevelop.
* User: jiacheo
* Date: 2011/5/6
* Time: 23:32
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
namespace zhidao
{
partial class MainForm
{
///
/// Designer variable used to keep track of non-visual components.
///
private System.ComponentModel.IContainer components = null;
///
/// Disposes resources used by the form.
///
/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
///
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
///
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(12, 12);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(128, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(12, 51);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.Button2Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(116, 51);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 23);
this.label1.TabIndex = 3;
this.label1.Text = "label1";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(409, 117);
this.Controls.Add(this.label1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Name = "MainForm";
this.Text = "zhidao";
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private CheckBox checkBox1 ;
void Button1Click(object sender, System.EventArgs e)
{
checkBox1 = new CheckBox();
checkBox1.Text = textBox1.Text;
checkBox1.Location = new System.Drawing.Point( 220, 12 );
this.Controls.Add(checkBox1);
}
void Button2Click(object sender, System.EventArgs e)
{
if(checkBox1!=null && checkBox1.Checked){
label1.Text = checkBox1.Text;
}
}
}
}