Solved

How do I add controls to tabs on the sstab control at run time.

Posted on 2001-07-13
4
361 Views
Last Modified: 2008-01-09
I want to write a program that will start with a single tab on a tabbed dialog control (sstab) and allow additional tabs to be added. Each tab will contain 2 command buttons, a textbox and 4 option buttons. The controls contained in the tab will be from control arrays.

The idea is that, when required, I will add a tab to the tabbed dialog control (easy enough). I will also load a new set of controls (easy enough since they are elements of control arrays).
The problem is that I want the controls to be placed on the tabs. If I use the code:
Set Command1.container = sstab1
Command1 is placed on the first tab.

Is there a way to place the control on a specific tab at run time?
0
Comment
Question by:chaos_59
4 Comments
 
LVL 39

Expert Comment

by:appari
ID: 6281778
try this

sstab1.tab = 1
Set Command1.container = sstab1


replace sstab1.tab with the tab no on which you want to show the new control. one more point to note don't do it in form load event. it's not working. write this code in activate event.

Rao

0
 
LVL 1

Expert Comment

by:khampton
ID: 6282133
I haven't worked with SSTAB since VB4.  A little while back, I tried to do exactly what you are doing with VB6.  After spending over an hour trying everything I could think of - I gave up and wrote my own SSTAB control.  Here is how I did it:


I created a UserControl.  I set this control to be a container of other controls.  I used Labels as tabs.  I created methods called AddTab and RemoveTab to dynamically increase/decrease the tabs at runtime.  When a user clicks on a tab (label) I raised an event.

The caller can put as many controls on the usercontrol as desired.  The caller is responsible for hiding/showing controls relative to a specific tab.

Anyway, the bottom line is now I have a tabbed control that I can do anything I want with (I can change colors, accent an open tab, etc).

Try it, its not really that hard...good luck!
0
 
LVL 5

Accepted Solution

by:
gwgaw earned 300 total points
ID: 6282614
Adding controls to the ssTab in form activate event will work but the
added controls may also be visible on the first tab.

The ssTab control does not have to be visible to add tabs or controls to a
specific tab but it must be initailized or all conrtols will be added to
first tab.

To add controls at startup, place a timer control on your form. Set it's
enabled property to false and the interval to a value that is large enuff
to allow your form to finish loading. Enable the timer on the last line
of form load event.


Private Sub Form_Load()
'Do form load stuff
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Dim i%
Timer1.Enabled = False
SSTab1.TabsPerRow = 4
For i = 2 To 4
    With SSTab1
        'Add a tab
        .Tabs = i
        'Make the added tab the current tab
        .Tab = .Tabs - 1
    End With
    Load Text1(Text1.Count + 1)
    With Text1(Text1.Count)
        'Place text box on the current tab
        .Container = SSTab1
        'Don't forget to set position
        .Left = 120
        .Top = 420
        .Visible = True
        .Text = SSTab1.Tab & " - " & .Index
    End With
Next i
End Sub


This can also be done in a command button's click event or in response to
some other user action. Use a For-Next or Do loop to add as many tabs and
controls as you want.
0
 
LVL 1

Author Comment

by:chaos_59
ID: 6286740
Thanks!
I almost had it, but your code showed me where my problems where.
Thanks so much!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now