problem tablelayoutpanel c# windows application

S

Sudha Pune

Hi all

i am using vs2005 C# window application

i am trying to add the controls dynamically inside the
"tablelayoutpanel", i need to add row by row and each row i will have
to have 10 columns and each column i need to add one control

If i try to do this the control coming one under one and not
horizontaly, what is missing here,,,,

tlp = new TableLayoutPanel();
tlp.Location = new Point(1, 24);
this.Controls.Add(tlp);

tlp.Controls.Add(txt_Code1, controlIndex,0);

tlp.Controls.Add(txt_Code2, controlIndex,1);

the above is bringing the second control down to the first control and
not beside to first control

i even tried the tlp.ColumnCount=2;

still same problem

help me out to come out of this problem

thanks a lot
 
A

Andrej Tozon

Hi,
your code seems fine. I tried the following code, which results in a
10x5 grid.

TableLayoutPanel tableLayoutPanel1 = new TableLayoutPanel();
tableLayoutPanel1.Dock = DockStyle.Fill;
this.Controls.Add(tableLayoutPanel1);
for (int row = 0; row < 5; row++)
{
for (int column = 0; column < 10; column++)
{
TextBox textBox = new TextBox();
textBox.Text = string.Format("TextBox({0}, {1}) ", column, row);
tableLayoutPanel1.Controls.Add(textBox, column, row);
}
}

Andrej
 
S

Sudha Pune

Hi thanks

And DockStyle only was missing in my code and so now i handled that
also... thanx a lot...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top