Tabs with a ToolStrip
Thursday, August 30th, 2007I’ve been working on a little text editor project recently and wanted a tabbed list of documents (ala Firefox). I found a couple free solutions on the web including a project on The Code Project, but I thought I could do one better. It occurred to me that it wouldn’t take much work to customize a ToolStrip to look and behave like tabs. Why make my own tab control when there already exist one you ask? Call me picky, but I’ve never like the TabControl that ships with .NET. I find it a little clunky. I also don’t like the look of the tab pages or that I have to place everything I want in the tab within a tab page. What I wanted was a control that was just the tabs and would let me decide what to show based on the tab selection events, and not the extra bloat that goes along with the TabControl. Yes I could just reduce the size of the TabControl so that only the tabs were showing but I’m not comfortable with the idea of hiding a big portion of the control just to show the part I wanted.
I’m happy to report that my little experiment is working perfectly! After setting a number of built-in properties on the ToolStrip and ToolStripButton to make them behave a little more like tabs it was simply a matter of creating a custom ToolStripRenderer to give it the appearance of tabs. That was also a breeze using the VisualStyleRenderer to give them the XP theme style of tabs.