KEMBAR78
Create Text Bio X | PDF
0% found this document useful (0 votes)
8 views2 pages

Create Text Bio X

Uploaded by

Bá Việt Lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Create Text Bio X

Uploaded by

Bá Việt Lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

private void btSubmit_Click(object sender, EventArgs e)

{
number = int.Parse(nuDButton.Value.ToString());
for(int i = 1; i <= number; i++)
{
Label label = new Label();
label.AutoSize = true;
label.Location = new System.Drawing.Point(64, 5+i*40);
label.Size = new System.Drawing.Size(90, 15);
label.TabIndex = 3;
label.Text = "Text of button"+i+":";
TextBox te = new TextBox();
te.Location = new System.Drawing.Point(171, 5+i*40);
te.Size = new System.Drawing.Size(130, 23);
this.Controls.Add(label);
this.Controls.Add(te);

}
Button btAdd = new Button();

btAdd.Location = new System.Drawing.Point(325, 371);


btAdd.Name = "btAddText";
btAdd.Size = new System.Drawing.Size(81, 28);
btAdd.TabIndex = 3;
btAdd.Text = "Add textbox";

//add.Click += new System.EventHandler(this.btAddText_Click);


btAdd.Click += new System.EventHandler(btAdd_Click);

this.Controls.Add(btAdd);
}

private void btAdd_Click(object sender, EventArgs e)


{
foreach(Control c in this.Controls)
{
if(c is TextBox)
{
// TextBox txt = (TextBox)c;

Button button = new Button();


button.Location = new System.Drawing.Point(c.Location.X +
c.Size.Width+55, c.Location.Y);
button.Size = new System.Drawing.Size(72, 29);
button.Text = c.Text;
button.Click += Button_Click;

this.Controls.Add(button);

}
}

private void Button_Click(object? sender, EventArgs e)


{
Button a = sender as Button;
MessageBox.Show("Button " + a.Text + " is clicked");
}

private void Form1_Load(object sender, EventArgs e)


{

You might also like