Pages

Thursday, August 15, 2013

A few simple techniques to change the appearance of tabs in a TabControl

By default, NET positions TabControl tabs at the top of the control and labels them with plain text. Unfortunately, you can't easily change the back color of the tab or the font of its text. However, that doesn't mean you have to settle for bland, boring tabs. Three simple adjustments you can make to TabControl tabs without writing a single line of code include: adding images to each tab, changing the position of the tabs, and stacking multiple tabs for easier viewing.

To add images to tabs:

  1. Add an ImageList to your project and select it.
  2. In the Properties window, use the Images property to add images to the ImageList collection.
  3. Add a TabControl to your form and select it.
  4. In the Properties window, use the dropdown list in the ImageList property to select the name of the ImageList you just created.
  5. Locate the TabPages property and click the ellipses in the field.
  6. Click the Add button to add a new TabPage and then use the dropdown list in the ImageIndex property to select the desired tab image.
  7. Repeat step 6 as needed.
To change the tab position:
  1. In the Properties window, locate the Alignment property for the TabControl.
  2. Change the value to Right, Bottom, or Left to reposition the group of tabs.
To remove the tab scrollbar:
  1. In the Properties window, locate the Multiline property for the TabControl and change the value to True.
One thing to keep in mind: Top and Bottom aligned tabs can be layered or scrolled, but Left and Right aligned tabs can only be layered.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.