简体   繁体   中英

How to change size and image in TabControl

I want to change size of TabPage in my TabControl , 在此输入图像描述

each tab should be in one line without scroll.

the second question is about how to change Text into Image like here (Please, ignore the green line):

在此输入图像描述

edit. I used Winforms.

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");

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM