Refer below code.
Code
C#
protected void Button1_Click(object sender, EventArgs e)
{
(((sender as Button).Parent as FlowLayoutPanel).Controls[1] as TextBox).Text = (sender as Button).Text;
}
private void OnAdd(object sender, EventArgs e)
{
FlowLayoutPanel panel = new FlowLayoutPanel();
Button btn = new Button();
btn.BackColor = Color.DarkGray;
btn.Height = 21;
btn.Width = 100;
btn.Text = textBox1.Text;
btn.Click += new EventHandler(Button1_Click);
panel.Controls.Add(btn);
TextBox txt = new TextBox();
txt.Name = "txt";
txt.Height = 21;
txt.Width = 100;
panel.Controls.Add(txt);
FlowLayoutPanel1.Controls.Add(panel);
textBox1.Text = "";
}
VB.Net
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
CType(CType(CType(sender, Button).Parent, FlowLayoutPanel).Controls(1), TextBox).Text = CType(sender, Button).Text
End Sub
Private Sub OnAdd(sender As Object, e As EventArgs) Handles button1.Click
Dim panel As FlowLayoutPanel = New FlowLayoutPanel
Dim btn As Button = New Button()
btn.BackColor = Color.DarkGray
btn.Height = 21
btn.Width = 100
btn.Text = textBox1.Text
AddHandler btn.Click, AddressOf Me.Button1_Click
panel.Controls.Add(btn)
Dim txt As TextBox = New TextBox()
txt.Name = "txt"
txt.Height = 21
txt.Width = 100
panel.Controls.Add(txt)
FlowLayoutPanel1.Controls.Add(panel)
textBox1.Text = ""
End Sub
Screenshot