Controls in TablelayoutPanel not getting arranged properly

S

Sujay Ghosh

Hi,

I am programmatically creating a TableLayout panel with 8 columns and 21
rows .
Within the cell I am placing some labels and checkboxes .

Then I dynamically add more rows , by calling my function UpdateTable( ).

private TableLayoutPanel tb = new TableLayoutPanel ().

private void UpdateTable( )
{

tb.SuspendLayout() ;

tb.GrowStyle = TableLayoutPanelGrowStyle.AddRows;

// assume LastRowCount = 21 , as I have added 21 rows earlier
// hence I increment LastRowCount in the for loop initialization

for( int i = LastRowCount+1 ; i< 20 ; i++
tb.RowStyles.Add( myRowStyle );

tb.ResumeLayout(false );

}

Strangely enough the following things happen

1) Calling UpdateTable() for the first time - Only one row gets added ;

2) Calling UpdateTable () for the second time - The checkboxes are getting
redrawn in DIFFERENT positions ... which is not desired .

For the second one, I think pending layouts are getting performed intenally
by the layout engine ...

Can anyone help me in getting answers to these problems .


Thanks in advance ,

Sujay
 
E

eliza sahoo

Fetching controls in TableLayoutPanel

Dim ctrlInLastRow(TablelayoutPnl.ColumnCount - 1) As Control

Dim IDLbl As New Label
Dim NameTxt As New TextBox

Dim IDStr As String = String.Empty
Dim NameStr As String = String.Empty


For Each ctrl As Control In TablelayoutPnl.Controls

Dim cell As TableLayoutPanelCellPosition = TablelayoutPnl.GetCellPosition(ctrl)

If cell.Row = TablelayoutPnl.GetRow(ctrl) Then
ctrlInLastRow(cell.Column) = ctrl
Select Case cell.Column
Case 0
IDLbl = CType(ctrl, Label)
IDStr = IDLbl.Text
Case 2
NameTxt= CType(ctrl, TextBox)
NameStr = NameTxt.Text

End Select
End If
Next

Here we can get the created label and text box's values according to the cell in the TablelayoutPanel.

thanks
Eliza
http://bit.ly/alOvM1



SujayGhos wrote:

Controls in TablelayoutPanel not getting arranged properly
06-Mar-08

Hi

I am programmatically creating a TableLayout panel with 8 columns and 21
rows
Within the cell I am placing some labels and checkboxes

Then I dynamically add more rows , by calling my function UpdateTable( )

private TableLayoutPanel tb = new TableLayoutPanel ()

private void UpdateTable(


tb.SuspendLayout() ;

tb.GrowStyle = TableLayoutPanelGrowStyle.AddRows

// assume LastRowCount = 21 , as I have added 21 rows earlier
// hence I increment LastRowCount in the for loop initializatio

for( int i = LastRowCount+1 ; i< 20 ; i+
tb.RowStyles.Add( myRowStyle )

tb.ResumeLayout(false )



Strangely enough the following things happe

1) Calling UpdateTable() for the first time - Only one row gets added

2) Calling UpdateTable () for the second time - The checkboxes are getting
redrawn in DIFFERENT positions ... which is not desired

For the second one, I think pending layouts are getting performed intenally
by the layout engine ...

Can anyone help me in getting answers to these problems

Thanks in advance

Suja


--
Sujay Ghos
Bangalore, INDIA

Previous Posts In This Thread:

Controls in TablelayoutPanel not getting arranged properly
Hi

I am programmatically creating a TableLayout panel with 8 columns and 21
rows
Within the cell I am placing some labels and checkboxes

Then I dynamically add more rows , by calling my function UpdateTable( )

private TableLayoutPanel tb = new TableLayoutPanel ()

private void UpdateTable(


tb.SuspendLayout() ;

tb.GrowStyle = TableLayoutPanelGrowStyle.AddRows

// assume LastRowCount = 21 , as I have added 21 rows earlier
// hence I increment LastRowCount in the for loop initializatio

for( int i = LastRowCount+1 ; i< 20 ; i+
tb.RowStyles.Add( myRowStyle )

tb.ResumeLayout(false )



Strangely enough the following things happe

1) Calling UpdateTable() for the first time - Only one row gets added

2) Calling UpdateTable () for the second time - The checkboxes are getting
redrawn in DIFFERENT positions ... which is not desired

For the second one, I think pending layouts are getting performed intenally
by the layout engine ...

Can anyone help me in getting answers to these problems

Thanks in advance

Suja


--
Sujay Ghos
Bangalore, INDIA


Submitted via EggHeadCafe - Software Developer Portal of Choice
Build a Self-Updating Windows Service Data Cache
http://www.eggheadcafe.com/tutorial...d9-47041e0465ce/build-a-selfupdating-win.aspx
 

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