-
Sep 26th, 2006, 10:12 PM
#1
[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:
Private Sub Command2_Click()
Dim cCount As Integer, i As Integer
cCount = 6
For i = 1 To cCount Step 1
Load cCompanies(i)
With cCompanies(i)
.Height = 400
.Top = .Height * i
.Visible = True
.ZOrder 1
End With
Load cCompaniesN(i)
With cCompaniesN(i)
.Top = cCompanies(i).Top + (cCompaniesN(i - 1).Top - cCompanies(i - 1).Top) 'cCompaniesN(i - 1).Top + cCompaniesN(i).Height
.Caption = "Test"
.Visible = True
.ZOrder 0
End With
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..
-
Sep 26th, 2006, 11:31 PM
#2
Re: Creating Controls Within a Container
You are correct, you need to set the Container property of the Label.
VB Code:
Load cCompaniesN(i)
With cCompaniesN(i)
Set .Container = cCompanies(i)
'The Label.Top and Left properties are relevant to the PictureBox control.
'the original line will position the label out of view
'.Top = Picture1(i).Top + (Label1(i - 1).Top - Picture1(i - 1).Top)
'Just start with 0,0
.Top = 0
.Left = 0
.Caption = "Test"
-
Sep 26th, 2006, 11:39 PM
#3
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.
-
Sep 27th, 2006, 12:47 AM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|