SSTab Control Code for Individual Tabs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beacon
    Contributor
    • Aug 2007
    • 579

    SSTab Control Code for Individual Tabs

    I am creating a form using the SSTab control. For the first tab I wanted more than one page and had to copy the control in order to achieve this. I then placed next page and previous page buttons off of the tab control that were set up to determine which of the tab controls were visible (SSTab1 or SSTab2).

    When I began to work on the second tab of SSTab1, I only wanted one page for the tab control, but I wanted to keep the command buttons I created in the same place, but write code that says something to the effect of "if tab 2 is selected, nextpagebutton. enable = false," however, I have been unable to find anything that would suggest that you can create events for individual tabs. Is this possible?
  • pureenhanoi
    New Member
    • Mar 2007
    • 175

    #2
    Originally posted by beacon
    I am creating a form using the SSTab control. For the first tab I wanted more than one page and had to copy the control in order to achieve this. I then placed next page and previous page buttons off of the tab control that were set up to determine which of the tab controls were visible (SSTab1 or SSTab2).

    When I began to work on the second tab of SSTab1, I only wanted one page for the tab control, but I wanted to keep the command buttons I created in the same place, but write code that says something to the effect of "if tab 2 is selected, nextpagebutton. enable = false," however, I have been unable to find anything that would suggest that you can create events for individual tabs. Is this possible?
    [CODE=vb]
    Private Sub SSTab1_Click()
    If SSTab1.Tab = 2 then cmdNextPage.Ena ble = False
    End Sub
    Private Sub cmdNextPage_Cli ck()
    SSTab1.Tab = SSTab1.Tab +1
    If SSTab1.Tab = 2 Then cmdNextPage.Ena ble=False
    End Sub
    Private Sub cmdSave_Click()
    Select Case SSTab1.Tab
    Case 1: 'Do something on page1
    Case 2: 'Do something on page2
    End Select
    End Sub
    [/CODE]

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Perhaps you could add some code to somewhere like the GotFocus events of all the client controls, to call a routine to record which tab they belong to (using .Parent property, maybe).

      Just thinking out loud here, of course.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by pureenhanoi
        Private Sub SSTab1_Click() ...
        But what if the user doesn't click on the tab? Does this event fire when they just use the controls within the tab?



        Perhaps one could simply interrogate the .Visible properties of the tab controls, or something.

        Comment

        • pureenhanoi
          New Member
          • Mar 2007
          • 175

          #5
          Originally posted by Killer42
          But what if the user doesn't click on the tab? Does this event fire when they just use the controls within the tab?



          Perhaps one could simply interrogate the .Visible properties of the tab controls, or something.
          If user doesnt click on the tab, we might not do anything.

          Let see about a general-property page. We have three button (Ok, Apply, Cancel) at the bottom of the form (not on the Tab). When you click Ok or Apply, you can save all items on all Tab, or save only the items on current Tab (its belong to you). If you save all items, no need to determine which tab is currently selected. If you save only items on current page, determine which tab is selected by Select..Case and do the save-code.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            What I was thinking is that during validation, for example, code might put the user back into a control on one tab or another. You know, the typical "Hey, you didn't enter this important field!" scenario. This sort of thing would have to be taken into account when determining which tab the user is in, as they may not have clicked anywhere.

            Comment

            • pureenhanoi
              New Member
              • Mar 2007
              • 175

              #7
              Originally posted by Killer42
              What I was thinking is that during validation, for example, code might put the user back into a control on one tab or another. You know, the typical "Hey, you didn't enter this important field!" scenario. This sort of thing would have to be taken into account when determining which tab the user is in, as they may not have clicked anywhere.
              Did you mean the code set the focus to the controls? If you've using SSTab, you will see that: althrougt the code can focus user to controls that isnot on current tab, but the tab doesnt change. Thats mean, the controls got focus in nearly visible (i said "nearly", because, if controls is on current tab, you still can see them). That program is in terrible. Because: we ask the user must complete the important fields, while doesnot show this field.
              To trap this error, we must determine which tab are the important fields in, and turn this tab on, before set focus to controls. E.x
              Code:
              Private Sub cmdSave_Click()
              Dim tab As Integer
              If (user forgot one important field)  Then
                 Msgbox "Hey, you didn't enter this important field!" 
                  tab = 'the tab that contains important field
                 SSTab1.Tab = tab
                 importantField.SetFocus
              End If
              End Sub
              The code SSTab1.Tab = tab will automatically raise SSTab1_Click() event.

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Yes, that's what I meant. The developer needs to be careful to catch this sort of situation.

                Comment

                Working...