Auto tab controls

I have a TabControl consisting of several TabPages. One of these tables contains a TreeView, and the other contains a DataGridView. I would like these controls (and tabs) to be in AutoSize to the maximum size allowed in TabControl without scrolling.

The DataGridView contains an AutoSize property inherited from the control that extinguishes the control if it is enabled. TreeView does not have this property. I tried to set the size to TabControl.Size, but that does not take into account the borderize and the height of the Tabbar.

treeView.Size = new Size(tabControl.Size.Width - SystemInformation.Border3DSize.Width * 2, tabControl.Size.Height - SystemInformation.Border3DSize.Height * 2);

My question is: how can I determine the height of the Tab buttons or how can I automatically populate the TabPages to their maximum size with a single control?

+3
source share
1 answer

The property you are looking for is called Dock .

You probably want to set it to DockStyle.Fillin TreeView and DataGridView.

An alternative would be to establish Anchorproperty AnchorStyle.Top, AnchorStyle.Left, AnchorStyle.Rightand AnchorStyle.Bottom(to combine the binary code or the pipe symbol '|'). To do this, you need to set the size of the childrenClientSize

+6
source

Source: https://habr.com/ru/post/1702973/


All Articles