Docked controls placed within TableLayout do not automatically size smaller than their creation size

蓝咒 提交于 2019-12-05 00:49:48

The tablelayoutpanel seems to store the initial size of the controls and never make them smaller regardless of docking, anchoring or any other values such as AutoSizeMode.GrowAndShrink. In designer the size of the docked control will always be stored, so the easiest method I've found is to set the width to 0 after the initializecomponent (since the control is docked, it won't actually resize the combobox, but it will allow the tablelayoutpanel to make it as small as the set width)

        InitializeComponent();
        comboField.Width = 0;

I downloaded your code and did this change. it works now -

Do the 2nd column's SizeType to percent and make it 100%

Designer Code:-

this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!