Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void tabControl1_DrawItem_1(object sender, DrawItemEventArgs e)
- {
- Graphics g = e.Graphics;
- Brush _textBrush;
- // Get the item from the collection.
- TabPage _tabPage = tabControl1.TabPages[e.Index];
- // Get the real bounds for the tab rectangle.
- Rectangle _tabBounds = tabControl1.GetTabRect(e.Index);
- if (e.State == DrawItemState.Selected)
- {
- // Draw a different background color, and don't paint a focus rectangle.
- _textBrush = new SolidBrush(Color.Black);
- g.FillRectangle(Brushes.White, e.Bounds);
- }
- else
- {
- _textBrush = new System.Drawing.SolidBrush(e.ForeColor);
- e.DrawBackground();
- }
- // Use our own font.
- Font _tabFont = new Font("Arial", (float)10.0, FontStyle.Bold, GraphicsUnit.Pixel);
- // Draw string. Center the text.
- StringFormat _stringFlags = new StringFormat();
- _stringFlags.Alignment = StringAlignment.Center;
- _stringFlags.LineAlignment = StringAlignment.Center;
- g.DrawString(_tabPage.Text, _tabFont, _textBrush, _tabBounds, new StringFormat(_stringFlags));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment