Results 1 to 3 of 3

Thread: Tab Page control inside a thread

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2021
    Posts
    30

    Tab Page control inside a thread

    Hello,

    I have been trying to switch between the tab pages inside a background running thread. Below I have attached a snippet of my thread code and If the value of i becomes 5 the tab page should be switched to another one automatically, but I don't know how this should be done. Can someone please help me with this?

    Code:
    For i= 0 To CInt(ARMNUMBER)+3
        If Quit Then
            Exit Sub
        End If
        Select Case i
            Case 0
                BlinkAB1 = True
    
            Case 1
                BlinkAB1 = False
                If confirm Then
                    pbAB1.Image = iLAB1.Images(1) 
                Else
                    pbAB1.Image = iLAB1.Images(0)
                End If        
                BlinkAB2 = True
    
            Case 2
                BlinkAB2 = False
                If confirm Then
                    pbAB2.Image = iLAB2.Images(1)
                Else
                    pbAB2.Image = iLAB2.Images(0)
                End If
                BlinkAB3 = True
    
            Case 3
                BlinkAB3 = False
                If confirm Then
                    pbAB3.Image = iLAB3New.Images(1)
                Else
                    pbAB3.Image = iLAB3New.Images(0)
                End If
                BlinkAB4 = True
    
            Case 4
                BlinkAB4 = False
                If confirm Then
                    pbAB4.Image = iLAB4.Images(1)
                Else
                    pbAB4.Image = iLAB4.Images(0)
                End If
                BlinkArm1 = True
    
            Case 5
                Me.tabControlGUI.SelectedIndex = 1  'Tab page changing process should be implemented here. This is what I have tried but it shows some error
    
                BlinkArm1 = False
                If confirm Then
                    pbARM1.Image = iLARM1.Images(1)
                Else
                    pbARM1.Image = iLARM1.Images(0)
                End If
                BlinkArm2 = True
    
            Case 6
                BlinkArm2 = False
                If confirm Then
                    pbARM2.Image = iLARM2.Images(1)
                Else
                    pbARM2.Image = iLARM2.Images(0)
                End If
                BlinkArm3 = True
    
            Case 7
                BlinkArm3 = False
                If confirm Then
                    pbARM3.Image = iLARM3.Images(1)
                Else
                    pbARM3.Image = iLARM3.Images(0)
                End If
                BlinkArm4 = True    
    
            Case 8
                    BlinkArm4 = False
                    If confirm Then
                        pbARM4.Image = iLARM4.Images(1)
                    Else
                        pbARM4.Image = iLARM4.Images(0)
                    End If
                BlinkArm5 = True
        End Select
    
       ' --------------------- some more code--------------------
    Next
    Last edited by dday9; May 7th, 2021 at 08:45 AM. Reason: formatted code

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    10,252

    Re: Tab Page control inside a thread

    If you are updating controls on a form from a separate thread, you will need to invoke the underlying form:
    Code:
    Invoke(Sub() tabControlGUI.SelectedIndex = 1)
    However, you should not be doing everything that you're doing in the separate thread to begin with. Could you explain why you set it up the way you did?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2021
    Posts
    30

    Re: Tab Page control inside a thread

    Quote Originally Posted by dday9 View Post
    If you are updating controls on a form from a separate thread, you will need to invoke the underlying form:
    Code:
    Invoke(Sub() tabControlGUI.SelectedIndex = 1)
    However, you should not be doing everything that you're doing in the separate thread to begin with. Could you explain why you set it up the way you did?
    Hello dday9,

    First of all, thank you for your response. The code you provided has done my work.
    I have called this thread into another event. If you remember, I have also mentioned in my earlier posts, the main function of this thread is to make the connection and communicate with the sensors used in my project. And the pictures of sensors are divided into many tab pages of one tab control. That is why I needed to change my tab page according to the sensor iteration value.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width