Click here to Skip to main content
14,176,972 members
Click here to Skip to main content
Add your own
alternative version

Stats

37.9K views
4.3K downloads
41 bookmarked
Posted 12 Jun 2016
Licenced CPOL

VisualStudio-Like TabControl

, 23 Aug 2016
Rate this:
Please Sign up or sign in to vote.
Inherits the awesome style of Visual Studio's TabControl for better exploiting

Introduction

Visual Studio IDE has a really awesome theme that everyone likes.

One of its best views is its customized and well-maintained TabControl, and that's why I made this usercontrol that looks like the TabControl used in Visual Studio.

Background

I (on an average) spend more than 10 hours using Visual Studio daily so I fell in love with its theme and wondered why don't I release a similar TabControl.

Youtube video

Youtube

Implementation

  • ActiveColor: Highlights the selected TabPage
  • BackTabColor: The color of the background of the TabPage
  • BorderColor: The border color of the control
  • ClosingButtonColor: The color of the closing button "X"
  • HeaderColor: The color of the Header
  • HorizontalLineColor: The color of the horizontal line that passes under the headers
  • SelectedTextColor: The color of the text of the selected page
  • TextColor: The color of the text

 

Layout

Using the Code

Using the code is the same for everyone who worked using the normal TabControl before, for more details about the standard TabControl, I suggest you take a look at TabControl MSDN.

Easy Usage

  1. Drag & drop the usercontrol on your Form
  2. Configure its properties through the properties box:

Advanced Usage

For a better performance and a more dynamic component, you can use many of this control's hidden features, one of them is the CloseButton feature that allows you to close a specific TabPage once you click on the "X" button, but that sounds so familiar and mainstream, so what? Here is the trick. :)

Without writing any line of code, you can make a Yes/No messagebox before closing the TabPage as the following picture shows:

Result:

Themes

One of the main tasks of this TabControl is to imitate the theme of Visual Studio IDE.

By default, the control's theme is set to Dark-Theme which is a combination of black, gray, blue and white.

In the samples Form, I did add three themes which are: Dark, Light and blue (they are also the standard themes of Visual Studio IDE).

As I did mention, the control is set to dark by default, but to get the blue, light theme or whatever you prefer, you have to edit the colors on your own using the properties window:

Light theme

To create a well-customized theme as the light theme, you have to let go of the mouse and use your hands a bit.

Light theme code:

this.visualStudioTabControl1.HeaderColor = Color.FromArgb(237 , 238 , 242);
this.visualStudioTabControl1.ActiveColor = Color.FromArgb(1, 122, 204);
this.visualStudioTabControl1.HorizontalLineColor = Color.FromArgb(1, 122, 204);
this.visualStudioTabControl1.TextColor = Color.Black;
this.visualStudioTabControl1.BackTabColor = Color.WhiteSmoke;
Blue theme

Code:

this.visualStudioTabControl1.HeaderColor = Color.FromArgb(54, 78, 114);
this.visualStudioTabControl1.ActiveColor = Color.FromArgb(247, 238, 153);
this.visualStudioTabControl1.HorizontalLineColor = Color.FromArgb(247, 238, 153);
this.visualStudioTabControl1.selectedTextColor = Color.Black;
this.visualStudioTabControl1.BackTabColor = Color.RoyalBlue;

I preferred writing bare code, but you can accomplish the same task using the properties window as well.

That's all of it, folks ♥ !

Points of Interest

Honestly, when I wrote the code, I used Visual Studio by then so I was looking at its TabControl and tried my best to copy it. haha :D .

 

History

• 6/14/2016 : Added a demonstration video.

• 8/23/2016 : Fixed some comments.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Alaa Ben Fatma
Student
Tunisia Tunisia
I am a 19 years old software developer & a university student. I am a curious person, I love learning about new things and meeting more experienced developers & engineers.
alaabenfatma[a]yahoo.fr

You may also be interested in...

Comments and Discussions

 
QuestionTrouble with Item.Height?! Pin
Chillchef27-Nov-18 4:56
memberChillchef27-Nov-18 4:56 
SuggestionMuch better version Pin
Aleksy Ruszała20-Nov-18 15:10
memberAleksy Ruszała20-Nov-18 15:10 
QuestionVery Nice! Pin
Cees Meijer20-Nov-18 0:12
memberCees Meijer20-Nov-18 0:12 
QuestionHow to call protected override void OnMouseDown(MouseEventArgs e) Pin
Alex Sigmanor20-Aug-18 7:37
memberAlex Sigmanor20-Aug-18 7:37 
QuestionChanging Tabs Broken Pin
Member 1370305921-Jul-18 17:47
memberMember 1370305921-Jul-18 17:47 
QuestionError when closing multiple tabs. Pin
Jov29-Mar-18 9:08
memberJov29-Mar-18 9:08 
GeneralNice work! I wrote an improved one (source available). Pin
atillabyte23-Feb-18 11:45
memberatillabyte23-Feb-18 11:45 
BugError DLL (VisualStudio-Like TabControl) Pin
Member 134120829-Oct-17 3:52
memberMember 134120829-Oct-17 3:52 
GeneralRe: Error DLL (VisualStudio-Like TabControl) Pin
Alaa Ben Fatma9-Oct-17 6:34
professionalAlaa Ben Fatma9-Oct-17 6:34 
BugLooks great~ doesn't work so well yet Pin
MAIsw2-Aug-17 23:11
memberMAIsw2-Aug-17 23:11 
GeneralThank you so much Pin
Member of Code Project :)26-Jul-17 5:58
memberMember of Code Project :)26-Jul-17 5:58 
Wow, this is a great custom tab control with nice theming support.
Questionright to left problem Pin
lookingforinnerpeace19-Apr-17 5:54
memberlookingforinnerpeace19-Apr-17 5:54 
AnswerRe: right to left problem Pin
Alaa Ben Fatma9-Oct-17 6:37
professionalAlaa Ben Fatma9-Oct-17 6:37 
QuestionMultyLine Pin
Broker_gm16-Mar-17 4:32
memberBroker_gm16-Mar-17 4:32 
BugError removing first tab Pin
Disactive14-Nov-16 3:46
memberDisactive14-Nov-16 3:46 
SuggestionBrush disposing and font scaling Pin
Daniel Leykauf23-Sep-16 6:27
memberDaniel Leykauf23-Sep-16 6:27 
GeneralRe: Brush disposing and font scaling Pin
Alaa Ben Fatma29-Sep-16 7:28
professionalAlaa Ben Fatma29-Sep-16 7:28 
QuestionWinForms? Pin
tlhIn`toq24-Aug-16 8:51
membertlhIn`toq24-Aug-16 8:51 
GeneralRe: WinForms? Pin
tlhIn`toq24-Aug-16 12:14
membertlhIn`toq24-Aug-16 12:14 
Questionvs like-tab in vc++ Pin
ericyan7116-Jun-16 4:21
memberericyan7116-Jun-16 4:21 
AnswerRe: vs like-tab in vc++ Pin
Alaa Ben Fatma16-Jun-16 16:41
professionalAlaa Ben Fatma16-Jun-16 16:41 
PraiseGreat! I like it! Pin
wmjordan13-Jun-16 16:26
professionalwmjordan13-Jun-16 16:26 
SuggestionRe: Great! I like it! Pin
Alaa Ben Fatma13-Jun-16 16:38
professionalAlaa Ben Fatma13-Jun-16 16:38 
GeneralRe: Great! I like it! Pin
wmjordan13-Jun-16 23:10
professionalwmjordan13-Jun-16 23:10 
QuestionAll images are broken Pin
Mauro Destro12-Jun-16 21:12
professionalMauro Destro12-Jun-16 21:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05 | 2.8.190526.1 | Last Updated 23 Aug 2016
Article Copyright 2016 by Alaa Ben Fatma
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid