简体   繁体   中英

.net tabcontrol tab sizes

I have a tab control where I'm using user painting to remove flickering. It's rendering fine in terms of flicker removal, but the tab widths are not right. There is a large amount of padding around the text that gets bigger as the length of the text on the tab increases. It's like the width of the tab is based on a font that is larger than the one that is being drawn. I have tried changing the size of the font on the tab control, but that has no effect on the tab widths.

How does the tab control determine the widths of the tabs? Is there something I can override so that I can supply the tab widths to the tab control?

Have you tried to enable double buffering to remove the flicker before using custom painting?

Just try to call this function in your control constructor and see how it works:

private void EnableDoubleBuffering()
{
   this.SetStyle(ControlStyles.DoubleBuffer | 
      ControlStyles.UserPaint | 
      ControlStyles.AllPaintingInWmPaint,
      true);
   this.UpdateStyles();
}

要更改选项卡的大小,您必须执行所说的Ian(在ItemSize中设置所需的大小)并将SizeMode属性设置为Fixed

TabControl具有一个称为ItemSize的属性,该属性的确用于通知TabControl其选项卡的大小。

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