Glenn
Glenn

Reputation: 5776

.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?

Upvotes: 2

Views: 4201

Answers (3)

Viktar
Viktar

Reputation: 129

To change the tab size you must to do what said Ian (set required size in ItemSize) and set SizeMode property to Fixed

Upvotes: 1

Ian
Ian

Reputation: 34489

The TabControl has a property called ItemSize which is indeed used to inform the TabControl as to the size of its tabs.

Upvotes: 0

Claudiu Mihaila
Claudiu Mihaila

Reputation: 1332

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();
}

Upvotes: 0

Related Questions