Solved

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

Posted on 2001-07-13
4
369 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

863 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

27 Experts available now in Live!

Get 1:1 Help Now