Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2001-07-13
4
Medium Priority
?
446 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 1200 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

715 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