|
-
Nov 18th, 2000, 07:52 PM
#1
Thread Starter
Junior Member
When using a picturebox as a container, how do you reference the controls that it contains? Kind of like the Form.Controls collection.
Thanks,
trapper
-
Nov 18th, 2000, 09:15 PM
#2
-
Nov 18th, 2000, 10:03 PM
#3
PowerPoster
Do you mean this?
Code:
Dim c As Control
For Each c In Picture1.Container
If TypeOf c Is Label Then Debug.Print "Label Control " & c
Next
-
Nov 18th, 2000, 10:36 PM
#4
Thread Starter
Junior Member
I think it's something different
I've always understood that picture1.container (with picture1 being a picturebox) returns the object that contains the picturebox, not a collection of the objects that the picturebox contains. Am I incorrect?
-
Nov 18th, 2000, 10:46 PM
#5
Well ...
No, I don't think you need to refer to the PictureBox control even if it is a container for other controls.
I have an array of CommandButtons on a PictureBox which is left-aligned on an MDI Form. I am able to reference the CommandButtons without referring to the PictureBox control.
Of course, if you mean you want to iterate through all controls on a PictureBox, then I got your question wrong. Still I shall try to find out how this is done.
-
Nov 19th, 2000, 12:17 AM
#6
Thread Starter
Junior Member
The second one
Right. I meant that I only want to reference the controls contained by a specific picturebox.
I had thought that I could create a collection of the controls contained in the picturebox when the form is loaded. Something like this:
Dim Cntrl as Control
Dim PictureCollection as Collection
For Each Cntrl in Form.Controls
If Cntrl.Container = picture1 then
PictureCollection.Add Cntrl
end if
Next
I think this would work. However, this seems awfully ineligant to me. Why would a picturebox or a frame be designed as a container if there were no simple way to reference the contained controls?
-
Nov 21st, 2000, 02:05 PM
#7
Thread Starter
Junior Member
Hmmm. That didn't quite work.
I think I'm having trouble comparing the pointers for Cntrl.Container and picture1. Any more suggestions out there?
Thanks,
trapper
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
|