At run time, give the form TabStrip and ImageList controls. Define tabs for the TabStrip but don't give them any text. Just set their Key and TooltipText properties.
Also create a PictureBox named picHidden with Visible = False and Index = 0.
The following code shows how the program builds the tabs' images when the program starts. It first creates an array containing the colors it will use for the tabs. It then clears the ImageList control and sets its image width and height.
Next the code loops through the tabs. For each tab, it makes and sizes a PictureBox, clears the PictureBox with the appropriate color, and draws the tab's Key value onto the PictureBox. It copies the resulting picture into the ImageList control.
The program then sets the TabStrip's ImageList property to the ImageList control (you must do this after creating the images) and then loops through the tabs again setting their Image properties to the indexes of their images in the ImageList (you must do this after setting the TabStrip's ImageList property).
|