Results 1 to 4 of 4

Thread: [RESOLVED] ITERATE control in picture

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    2,353

    Resolved [RESOLVED] ITERATE control in picture

    Code:
    Private Sub LOOP_BUTTON()
    
        Dim CTRL As Control
        For Each CTRL In Picture.Container
            MsgBox CTRL.Name
        Next
    
    End Sub
    my poor code...

    have error in Picture.Container (error 438)

    i need to get for each commandbutton(in black circle) the name

    note:
    picturebox is named picture
    Last edited by luca90; Aug 8th, 2022 at 04:53 PM.

  2. #2
    Addicted Member
    Join Date
    Jan 2018
    Posts
    217

    Re: ITERATE control in picture

    The Container property does the reverse of what you are expecting, you want:

    Code:
        For Each CTRL In Me.Controls
            If CTRL.Container Is Picture And TypeName(CTRL) = "CommandButton" Then
                MsgBox CTRL.Name
            End If
        Next
    If you have multiple levels of containers, you might have to write a recursive function to check for that...

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    2,353

    Re: ITERATE control in picture

    Quote Originally Posted by ahenry View Post
    The Container property does the reverse of what you are expecting, you want:

    Code:
        For Each CTRL In Me.Controls
            If CTRL.Container Is Picture And TypeName(CTRL) = "CommandButton" Then
                MsgBox CTRL.Name
            End If
        Next
    If you have multiple levels of containers, you might have to write a recursive function to check for that...
    in other case your code work perfect!

    Hi!
    Have an idea to check only on tab(0) of sstab?
    In effect i need to clear alls textbox and combobox.text

    my test:

    Code:
    Private Sub PULISCI_ANAGRAFICA()
    
    Dim CTRL As Control
        For Each CTRL In Me.Controls
            If CTRL.Container Is Me.SSTab.Tab(0) Then
                If TypeName(CTRL) = "TextBox" Or TypeName(CTRL) = "ComboBox" Then
                    CTRL.Text = ""
                End If
            End If
        Next CTRL
    
    End Sub
    Last edited by luca90; Aug 10th, 2022 at 12:07 AM.

  4. #4
    Addicted Member
    Join Date
    Jan 2018
    Posts
    217

    Re: [RESOLVED] ITERATE control in picture

    I don't think SSTab publicly exposes which control is on which tab. You can check if the control is on the current tab by checking the Left value, or put everything in a tab into a borderless frame or picturebox, like if you were using TabStrip.

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