.net tab tab

I have a tab control where I am using a custom painting to remove the flicker. It handles fine in terms of flicker removal, but the caps width is wrong. A significant amount of padding around the text becomes larger as the length of the text in a tab increases. It's like the width of the tab is based on a font that is larger than the one being drawn. I tried changing the font size in the tab control, but that doesn't affect the tab width.

How does a tab control determine the width of tabs? Is there something I can override so that I can put the tab width in a tab control?

+2


source to share


3 answers


Have you tried enabling double buffering to remove flicker before using custom paint?

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

      

0


source


The TabControl has an ItemSize property that is actually used to inform the TabControl about the size of its tabs.



0


source


To resize the tab you have to do what Ian said (set the required size to ItemSize) and set the SizeMode property to Fixed

0


source







All Articles