Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have used tablelayoutpanel which consists of different controls in each row, that are made invisible and visible based on the configuration settings.

The following code below computes the size of rows which contain invisible controls inorder to resize the form when the controls are made invisible, but the size returned for row styles set to autosize is 0.
C#
private void ResizeForm(TableLayoutPanel tlp, Control ctrl)
{
    TableLayoutPanelCellPosition pos = tlp.GetCellPosition(ctrl);

    int height = tlp.GetRowHeights()[pos.Row];

    this.Height = this.Height - height;
}

Is there any other way to calculate the width of cell of tablelayoutpanel?
Posted
Updated 2-Dec-15 23:19pm
v2
Comments
deepankarbhatnagar 3-Dec-15 7:49am    
Please explain more clearly...
CHill60 13-Dec-15 18:20pm    
If I use GetRowHeights when controls are visible I get the row height. If the controls are not visible then I get 0 (or occasionally 1) - which makes sense, no height is required if the controls are not visible. So what is the problem?
Also did you mean width or height?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900