Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating form with TabStrips 1

Status
Not open for further replies.

Terpsfan

Programmer
Dec 8, 2000
954
US
I'm creating a Visual Basic 6.0 front end to a SQL 7.0 DB. The interface I want to create is a main form with basic loan information. On this form I want to create tabs that would open up separate forms related to the main form. I know how to do this in Access, but not sure about how to do this is VB. The tabbed forms are from separate tables, each related to the main form(table) by a primary key.
 
The idea of using a tabbed dialog control (TabStrip being one such control) is so that you do not need to have multiple forms. Each of the tabs acts like a form, where you can add controls. The container for the controls is the tab that you are placing them on, rather than a form.

Simon
 
I know that much. For whatever reason I'm not able to put controls on the different tabs in design view. I'm not able to click on the different tabs in design view either.
 
A lengthy reply taken from help files, but you may (will) find it useful (I did when I first used the control) - by the way, I misled you when I said that the tab control is the container for the controls. This is not the case with TabStrip, but it is with ohters.

A brief summary of the following, is that you have to place frames on top of the tab strip and put controls in the frames. Then on Click of the tab strip, set the visible property of the frames to view the required frame / controls.

Help file:

A TabStrip control is like the dividers in a notebook or the labels on a group of file folders. By using a TabStrip control, you can define multiple pages for the same area of a window or dialog box in your application.

Syntax

TabStrip

Remarks

The control consists of one or more Tab objects in a Tabs collection. At both design time and run time, you can affect the Tab object's appearance by setting properties. You can also add and remove tabs using the Properties Page of the TabStrip control at design time, or add and remove Tab objects at run time using methods.

The Style property determines whether the TabStrip control looks like push buttons (Buttons) or notebook tabs (Tabs). At design time when you put a TabStrip control on a form, it has one notebook tab. If the Style property is set to tabTabs, then there will be a border around the TabStrip control's internal area. When the Style property is set to tabButtons, no border is displayed around the internal area of the control, however, that area still exists.

To set the overall size of the TabStrip control, use its drag handles and/or set the Top, Left, Height, and Width properties. Based on the control's overall size at run time, Visual Basic automatically determines the size and position of the internal area and returns the Client-coordinate properties – ClientLeft, ClientTop, ClientHeight, and ClientWidth. The MultiRow property determines whether the control can have more than one row of tabs, the TabWidthStyle property determines the appearance of each row, and, if TabWidthStyle is set to tabFixed, you can use the TabFixedHeight and TabFixedWidth properties to set the same height and width for all tabs in the TabStrip control.

The TabStrip control is not a container. To contain the actual pages and their objects, you must use Frame controls or other containers that match the size of the internal area which is shared by all Tab objects in the control. If you use a control array for the container, you can associate each item in the array with a specific Tab object, as in the following example:

Option Explicit
Private mintCurFrame As Integer' Current Frame visible

Private Sub Tabstrip1_Click()
If Tabstrip1.SelectedItem.Index = mintCurFrame _
Then Exit Sub ' No need to change frame.
' Otherwise, hide old frame, show new.
Frame1(Tabstrip1.SelectedItem.Index).Visible = True
Frame1(mintCurFrame).Visible = False
' Set mintCurFrame to new value.
mintCurFrame = Tabstrip1.SelectedItem.Index
End Sub

Note When grouping controls on a container, you must use the show/hide strategy shown above instead of using the Zorder Method to bring a frame to the front. Otherwise, controls that implement access keys (ALT + access key) will still respond to keyboard commands, even if the container is not the topmost control. Also note that you must segregate groups of OptionButton controls by placing each group on its own container, or else all OptionButtons on the form will behave as one large group of OptionButtons.

Tip Use a Frame control with its BorderStyle set to None as the container instead of a PictureBox control. A Frame control uses less overhead than a PictureBox control.

The Tabs property of the TabStrip control is the collection of all the Tab objects. Each Tab object has properties associated with its current state and appearance. For example, you can associate an ImageList control with the TabStrip control, and then use images on individual tabs. You can also associate a ToolTip with each Tab object.

Distribution Note The TabStrip control is part of a group of custom controls that are found in the MSCOMCTL.OCX file. To use the TabStrip control in your application, you must add the MSCOMCTL.OCX file to the project. When distributing your application, install the MSCOMCTL.OCX file in the user's Microsoft Windows SYSTEM folder. For more information on how to add a custom control to a project, see the Programmer's Guide.


Simon
 
The Tabstrip control doesn't seem to be a viable option. You mentioned other tab controls that act as containers. Which ones would you suggest and what references would I have to cite to use them? Thanks for your help.
 
Rather than TabStrip, I suggest you to use MS Tabbed Dialog Control (SSTab, filename : Tabctl32.ocx).

I found it is more flexible than Tabstrip.
 
as suggested by oneshadow, omega36 you try using sstab instead of tabstrip.sstab is more flexible and robust than tabstrip.
have a nice time in working with sstab.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top