I have created a function which add a row in tablelayoutpanel and textbox in column of the row. After adding few rows, i want to read the value of particular textbox in particular row. How can it be done. Remember one thing that name of all textbox is same in all row.
Here is the code snippit.
private void addtextbox(int x,int j)
{
int rowIndex = AddTableRow();
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
Label lbl = new Label();
TextBox Text1 = new TextBox();
TextBox Text2 = new TextBox();
TextBox Text3 = new TextBox();
TextBox Text4 = new TextBox();
lbl.Text = rowIndex.ToString();
tableLayoutPanel1.Controls.Add(lbl, 0, rowIndex);
tableLayoutPanel1.Controls.Add(Text1, 1, rowIndex);
tableLayoutPanel1.Controls.Add(Text2, 2, rowIndex);
tableLayoutPanel1.Controls.Add(Text3, 3, rowIndex);
tableLayoutPanel1.Controls.Add(Text4, 4, rowIndex);
//MessageBox.Show(tableLayoutPanel1.Controls. );
}
private int AddTableRow()
{
int index = this.tableLayoutPanel1.RowCount++;
RowStyle style = new RowStyle(SizeType.AutoSize);
tableLayoutPanel1.RowStyles.Add(style);
//detailTable.RowStyles.Add(style);
return index;
}