Results 1 to 4 of 4

Thread: PictureBox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    120

    PictureBox

    hi,
    I have a pictureBox and it contains few comboBoxes with lables, how can i loop thro all the ComboBoxes and Lables in the PictureBox?
    I tried using the following code but it did not work..

    Code:
        Dim c As Control
        
        For Each c In PictureBox.Controls
        	If TypeOf c Is ComboBox Then MsgBox "Comob"
    	If TypeOf c Is Label Then MsgBox "Label"
        next c
    Thanks
    Manzoor

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    use picturebox.parent instead of picturebox.controls.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Check the container name:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim c As Control
    3.  
    4. For Each c In Me
    5.     If c.Container.Name = "Picture1" Then
    6.         If TypeOf c Is ComboBox Then
    7.             MsgBox "Combobox in the picturebox: " & c.Name
    8.         End If
    9.         If TypeOf c Is Label Then
    10.             MsgBox "Label in the picturebox: " & c.Name
    11.         End If
    12.     End If
    13. Next c
    14. End Sub
    <removed by admin>

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    120
    Originally posted by MidgetsBro
    Check the container name:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim c As Control
    3.  
    4. For Each c In Me
    5.     If c.Container.Name = "Picture1" Then
    6.         If TypeOf c Is ComboBox Then
    7.             MsgBox "Combobox in the picturebox: " & c.Name
    8.         End If
    9.         If TypeOf c Is Label Then
    10.             MsgBox "Label in the picturebox: " & c.Name
    11.         End If
    12.     End If
    13. Next c
    14. End Sub
    Hey thanks all, MidgetsBro
    it is working!

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