How to change size and image in TabControl

自作多情 提交于 2019-12-01 22:14:27

Ad 1.

There is no way to adjust width of tab pages to fit width you want automatically, so you just have to do some maths to achieve this.

Ad 2.

First you have to create an ImageList object, which you will then pass to your TabControl:

ImageList il = new ImageList();
il.Images.Add("your_graphics_name", Image.FromFile(@"C:\Graphics\example.png"));
(...)
yourTabControl.ImageList = il;

Then you can set specific image from your image list on your tab page by giving it's key:

yourTabControl.TabPages.Add("title", "text", "your_graphics_name");
Levi Botelho

The size and layout of tabs is quite strictly controlled in WinForms. You can of course change the font and font size which will have an implicit effect on the size of the tabs, but this isn't what you want to do by the sounds of things.

Now apparently Windows does allow you to regulate the minimum default tab width, but you can't do it directly with the out-of-the-box WinForm control. This article explains how: How can i make WinForms TabPage header width fit it's title?.

You may want to consider a 3rd party tab control if this begins to pose a serious problem for you design-wise.

Like others said you can't change width of your tabs. But you can make your tabs for example in two rows, if they don't match the screen:

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