Need to improve the look of my owner draw tab controls in C# WinForms

I created this custom Tab Control, but do not have it the way I want it.

I want to draw a touch of red on the selected tab, like in the attached image, but I could not figure out how. Instead, I got it drawing the text in red. That's problem #1. How do I get it to draw it the way the artist is asking me to do it?

#2, the borders look squeezed and bulky. I needed to set tabArea and tabTextArea inside the DrawRedTab and DrawBlackTab functions since the area was a function of the selected tab. I wonder if that caused the borders to get all croweded looking.

Please have a look and find what I may be doing wrong, if you'd be so kind.

Thanks,
newbieweb
Rectangle tabArea;
        RectangleF tabTextArea;
        tabControl2.DrawItem += new DrawItemEventHandler(DrawOnTab);


        // Declares the event handler DrawOnTab which is a method that
        // draws a string and Rectangle on the tabPage1 tab.
        private void DrawOnTab(object sender, DrawItemEventArgs e)
        {
            int index = 0;
            foreach (TabPage tabPage in tabControl2.TabPages)
            {
                if (tabPage == tabControl2.SelectedTab)
                {
                    DrawRedTab(tabPage, index++, e);
                }
                else
                {
                    DrawBlackTab(tabPage, index++, e);
                }
            }
        }

        private void DrawRedTab(TabPage tabPage, int index, DrawItemEventArgs e)
        {
            tabArea = tabControl2.GetTabRect(index);
            tabTextArea = (RectangleF)tabControl2.GetTabRect(index);

            Graphics g = e.Graphics;
            Pen p = new Pen(Color.Blue);
            Font font = new Font("Arial", 10.0f);
            SolidBrush brush = new SolidBrush(Color.Red);

            g.DrawRectangle(p, tabArea);
            g.DrawString(tabPage.Text, font, brush, tabTextArea);
        }

        private void DrawBlackTab(TabPage tabPage, int index, DrawItemEventArgs e)
        {
            tabArea = tabControl2.GetTabRect(index);
            tabTextArea = (RectangleF)tabControl2.GetTabRect(index);

            Graphics g = e.Graphics;
            Pen p = new Pen(Color.Blue);
            Font font = new Font("Arial", 10.0f);
            SolidBrush brush = new SolidBrush(Color.Black);

            g.DrawRectangle(p, tabArea);
            g.DrawString(tabPage.Text, font, brush, tabTextArea);
        }

Open in new window

TabArtwork.png
newbiewebSr. Software EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

greatsubashCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
newbiewebSr. Software EngineerAuthor Commented:
I can't download any source code. The Zip contains an EXE and a DLL. So I am stick on the first link.

The second is C++ and I don't use C++.

If you can find how to get DrawTab to be called, then I may be able to take it from there. Otherwise I'm stuck.


newbieweb
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.