I'm creating a Windows C#/.NET app, and I'm trying to use a TabControl with the Appearance set to Buttons. I want the tabs to have images only, no text. However, I'm getting a bunch of extra padding on the right side of each button, which I'd like to get rid of:

I am able to reduce the right margin by reducing the font size to 1, but it's still a few pixels wider than the left side, and it seems a bit kludgy. Is there a better way?
Try This
public frmForm()
{
InitializeComponent();
tabControl1.Appearance = TabAppearance.Buttons;
tabControl1.DrawMode = TabDrawMode.OwnerDrawFixed;
tabControl1.DrawItem += new DrawItemEventHandler(tabControl1_DrawItem);
}
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
//Load the image
Image img = Image.FromFile(String.Format("{0}\\{1}.jpg",Application.StartupPath,tabControl1.TabPages[e.Index].Name));
//Resize image
img = new Bitmap(img, e.Bounds.Size);
//Draw on Tab Button
e.Graphics.DrawImage(img, e.Bounds.Location);
}

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With