Solved

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

Posted on 2001-07-13
4
401 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

749 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