Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Table Layout Panel Remove Control issue
 

Table Layout Panel Remove Control issue

I am trying to add/remove controls from TableLayoutPanel dynamically. Basic layout has 3 controls , one row and 2 columns, with GrowStyle set to AddRows. When additional controls are added, new row is added to the panel without any issues. I have code to add a new Row Style ( with SizeType as percent) and update the Row Count. THere are no issues with adding multiple controls and the panel size increases as expected by adding more rows.

Issue that I am seeing is when the last control of row is removed, I was hoping to remove the row and shrink the size of the layout panel. But, layout panel size is being maintained without shrinking for the removed row. I tried by setting AutoSizeMode propert to GrowAndShrink, hoping that when a row is removed, panel size would shrink proportionately. This attempt failed.

Are there any other options? which would allow the panel size to shrink when a row is removed. ( Similar to panel size increase when row is added).

Please provide your feedback. Thanks.
leelu01  Wednesday, June 17, 2009 5:48 AM
Hi Leelu,

Have you set the AutoSize property of the TableLayoutPanel to true?

I performed a test on this issue. When I remove controls from the TableLayoutPanel, the TableLayoutPanel shrinks while the last row is deleted. I set the TableLayoutPanel's AutoSize propertyto true, the AutoSizeMode property to GrowAndShrink and the GrowStyle propery to AddRows.

Sincerely,
Linda Liu
Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Monday, June 29, 2009 8:29 AM
Hi Leelu,

Have you set the AutoSize property of the TableLayoutPanel to true?

I performed a test on this issue. When I remove controls from the TableLayoutPanel, the TableLayoutPanel shrinks while the last row is deleted. I set the TableLayoutPanel's AutoSize propertyto true, the AutoSizeMode property to GrowAndShrink and the GrowStyle propery to AddRows.

Sincerely,
Linda Liu
Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Monday, June 29, 2009 8:29 AM

You can use google to search for other answers

Custom Search

More Threads

• This forum has moved the week of 12/8/2008
• How to add a custom control to Toolbox?
• C# Winform and adding a button to the titlebar
• toolbar in vb.net
• Set collection item value through PropertyDescriptor?
• Inherited Binding Source can not be accessed and cause error when i try to use it as a data source for another binding source
• Form border color
• How can I call a function in parent form from within user control?
• How do I retrieve current Project Name and Path for form currently open in the designer
• DesignTime licensing in a PopUp form which runs via verbs