Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 179205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:21:58+00:00 2026-05-11T14:21:58+00:00

I have the following code under a TabConttrols DrawItem event that I am trying

  • 0

I have the following code under a TabConttrols DrawItem event that I am trying to extract into a class file. I am having trouble since it is tied to an event. Any hints or pointers would be greatly appreciated.

        private void tabCaseNotes_DrawItem(object sender, DrawItemEventArgs e)     {         TabPage currentTab = tabCaseNotes.TabPages[e.Index];         Rectangle itemRect = tabCaseNotes.GetTabRect(e.Index);         SolidBrush fillBrush = new SolidBrush(Color.Linen);         SolidBrush textBrush = new SolidBrush(Color.Black);         StringFormat sf = new StringFormat                               {                                   Alignment = StringAlignment.Center,                                   LineAlignment = StringAlignment.Center                               };          //If we are currently painting the Selected TabItem we'll         //change the brush colors and inflate the rectangle.         if (System.Convert.ToBoolean(e.State & DrawItemState.Selected))         {             fillBrush.Color = Color.LightSteelBlue;             textBrush.Color = Color.Black;             itemRect.Inflate(2, 2);         }          //Set up rotation for left and right aligned tabs         if (tabCaseNotes.Alignment == TabAlignment.Left || tabCaseNotes.Alignment == TabAlignment.Right)         {             float rotateAngle = 90;             if (tabCaseNotes.Alignment == TabAlignment.Left)                 rotateAngle = 270;             PointF cp = new PointF(itemRect.Left + (itemRect.Width / 2), itemRect.Top + (itemRect.Height / 2));             e.Graphics.TranslateTransform(cp.X, cp.Y);             e.Graphics.RotateTransform(rotateAngle);             itemRect = new Rectangle(-(itemRect.Height / 2), -(itemRect.Width / 2), itemRect.Height, itemRect.Width);         }          //Next we'll paint the TabItem with our Fill Brush         e.Graphics.FillRectangle(fillBrush, itemRect);          //Now draw the text.         e.Graphics.DrawString(currentTab.Text, e.Font, textBrush, (RectangleF)itemRect, sf);          //Reset any Graphics rotation         e.Graphics.ResetTransform();          //Finally, we should Dispose of our brushes.         fillBrush.Dispose();         textBrush.Dispose();     } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:21:58+00:00Added an answer on May 11, 2026 at 2:21 pm

    Depends on what you’re trying to achieve. You could always sub class TabControl or you could encapsulate the drawing code in a class that you pass a TabControl to.

    public class TabRenderer {     private TabControl _tabControl;      public TabRenderer(TabControl tabControl)     {         _tabControl = tabControl;         _tabControl.DrawMode = TabDrawMode.OwnerDrawFixed;         _tabControl.DrawItem += TabControlDrawItem;     }      private void TabControlDrawItem(object sender, DrawItemEventArgs e)     {         // Your drawing code...     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code which works under V2 and I am trying to
I have the following code that works under linux. I want to port it
i have the following code to be implemented into my xaml file. <ItemsControl ItemsSource={Binding
I have the following code. (You can copy it into a file to debug
I have the following code iam trying to make the text div under the
Under $(document).ready(function() , I have the following code: num = $(#mainContentCategoryLinksWrapper > div).size(); This
I have following piece of code: It compiles without problems under gcc-3.4, gcc-4.3, intel
I have following code class User attr_accessor :name end u = User.new u.name =
I wrote the following code under the assumption that Excel will die with Monkey:
I have the following code: public class Parent { public string MyField { get;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.