PDA

View Full Version : Solved: How can I test a Form Label to see if it is contained in a given Form Frame?



xltrader100
01-23-2009, 04:28 PM
And wouldn't I have to know this if I'm asking the Label for it's current .Top .Left etc? Those numbers would be different depending on whether the Label was in a frame.

xld
01-23-2009, 05:06 PM
ControlName.Parent.Left

xltrader100
01-23-2009, 06:14 PM
Thank-you. So, then to find out if the first frame was within another frame, etc. I would parent.parent.parent my way out to get back to the form? Is there a more elegant way to loop through an unknown nest of frames?

Actually, I'd like to broaden the question just a bit to what I should have asked in the first place: Is there any way to get the names of all the controls contained in a frame? As opposed to just being at the right physical coordinates but not "belonging" to the frame?

xld
01-24-2009, 04:18 AM
Thank-you. So, then to find out if the first frame was within another frame, etc. I would parent.parent.parent my way out to get back to the form? Is there a more elegant way to loop through an unknown nest of frames?

Yes, but you should test to see whether the paren (and the grandparent) actually exist and is not the userform so that you know when to stop.


Actually, I'd like to broaden the question just a bit to what I should have asked in the first place: Is there any way to get the names of all the controls contained in a frame? As opposed to just being at the right physical coordinates but not "belonging" to the frame?




Dim ctl As msforms.Control

For Each ctl In Frame1.Controls

Debug.Print ctl.Name & ", left = " & ctl.Left & ", top = " & ctl.Top
Next ctl

xltrader100
01-24-2009, 11:26 AM
Great. Just what I was looking for. Thanks.