Results 1 to 4 of 4

Thread: [RESOLVED] Creating Controls Within a Container

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Resolved [RESOLVED] Creating Controls Within a Container

    I've already created the controls, however I want to create them inside a container which I've also created programmatically, and have no clue how I should go about doing this, or if it's even possible. In this case, the controls I'm making are basically just being cloned from a control array I already have on the IDE.
    VB Code:
    1. Private Sub Command2_Click()
    2.   Dim cCount As Integer, i As Integer
    3.   cCount = 6
    4.   For i = 1 To cCount Step 1
    5.     Load cCompanies(i)
    6.     With cCompanies(i)
    7.       .Height = 400
    8.       .Top = .Height * i
    9.       .Visible = True
    10.       .ZOrder 1
    11.     End With
    12.  
    13.     Load cCompaniesN(i)
    14.     With cCompaniesN(i)
    15.       .Top = cCompanies(i).Top + (cCompaniesN(i - 1).Top - cCompanies(i - 1).Top) 'cCompaniesN(i - 1).Top + cCompaniesN(i).Height
    16.       .Caption = "Test"
    17.       .Visible = True
    18.       .ZOrder 0
    19.     End With
    20. End Sub
    cCompaniesN is an array of labels, and cCompanies is an array of Picture Boxes, I want the labels to be contained in each corresponding picture box, because otherwise the labels won't be shown if they are underneath the box (labels = light control, picture box = heavy control, so ZOrder does nothing).

    I'm assuming it has something to do with the .Container property, but so far anything I've tried has proved futile, and usually ends up with a type mismatch of some kind...

    Anyone have any ideas? Any help would be appreciated..
    Like Archer? Check out some Sterling Archer quotes.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Creating Controls Within a Container

    You are correct, you need to set the Container property of the Label.

    VB Code:
    1. Load cCompaniesN(i)
    2. With cCompaniesN(i)
    3.     Set .Container = cCompanies(i)
    4.     'The Label.Top and Left properties are relevant to the PictureBox control.
    5.     'the original line will position the label out of view
    6.     '.Top = Picture1(i).Top + (Label1(i - 1).Top - Picture1(i - 1).Top)
    7.     'Just start with 0,0
    8.     .Top = 0
    9.     .Left = 0
    10.     .Caption = "Test"

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Creating Controls Within a Container

    oooh, I see. I didn't think to use Set, I was trying .Container=var, and kept getting mismatches, I even tried setting it to the control's handle. thanks a bunch.

    I used to live in BC (Fort St. John, to be exact), but moved to Alberta a few months ago. I'm going to assume you live in the more southern area, either way it's a good place.

    I can't try this right now, but I will soon. I'll rate you if it works out.
    Like Archer? Check out some Sterling Archer quotes.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Creating Controls Within a Container

    oh. and yeah, about the .Top, I forgot to change it, before I was using Shapes instead of PictureBoxes, because when I first started I wasn't planning on having the Shapes needing to be clicked on, and seeing as how the Shape doesn't have the Click/MouseOver/MouseDown properties, I changed it. anyway! thanks again.
    Like Archer? Check out some Sterling Archer quotes.

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