schworak
asked on
Container control with sub containers
I have a project where I want to create a control that allows part of the control to be a container control is this posible?
Imagine this... A single control with 2 frames in it. One frame (left) contains text data and the other frame (right) the user can add their own controls to.
But I don't want the user to be able to add their controls outside of the right frame. Is this posible? If so how?
If someone can help me make this work I will increase the points on this question.
Imagine this... A single control with 2 frames in it. One frame (left) contains text data and the other frame (right) the user can add their own controls to.
But I don't want the user to be able to add their controls outside of the right frame. Is this posible? If so how?
If someone can help me make this work I will increase the points on this question.
Hi Tim
I know that this isn't my question, but I just tried your code and it gave me an error message in the second line saying 'object doesn't support this method or property'.
Do I have to make some kind of reference before it will work?
I know that this isn't my question, but I just tried your code and it gave me an error message in the second line saying 'object doesn't support this method or property'.
Do I have to make some kind of reference before it will work?
Dim t As Textbox
Set t = Me.Controls.Add("VB.Textbo
With t
.Visible = True
.Top = 100
.Left = 100
.Text = "Here I Am"
End With
The Frame1 parameter doesn't need to be in quotes.
You shouldn't be getting that error message, based on the above I would not have been surprised at a type mismatch error.
You shouldn't need any sort of reference, however if you are using VB5 then this doesn't work I am afraid.
Yes, it worked without the quotes around Frame1. Thanks for clearing that up...
P.S I got that error in VB5 but tried the second time with VB6, and as you pointed out I got a type mismatch error.
ASKER
Maybe I am not grasping the function of the answer. How does that help?
That dynamically adds the textbox (or what ever) the the frame which is great, but I am trying to control the process at design time when a user uses my control (the one with 2 frames) and trys to drop a new object into my container control.
If I can catch (or detect) where they are dropping their control I can record the information somehow. I can then make sure the control lands and then stays within the second frame area.
Much like if you create a picture box then put two frames in it. I only want stuff to be dropped on the frame on the right not on the left.
That dynamically adds the textbox (or what ever) the the frame which is great, but I am trying to control the process at design time when a user uses my control (the one with 2 frames) and trys to drop a new object into my container control.
If I can catch (or detect) where they are dropping their control I can record the information somehow. I can then make sure the control lands and then stays within the second frame area.
Much like if you create a picture box then put two frames in it. I only want stuff to be dropped on the frame on the right not on the left.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Took me a minute to realize this but that only works at run time. Which is great but switching the parent at that time isn't much value.
I am trying to do it at design time.
Control11 is all compiled and ready.
Form1 is in design mode.
I am having some success with a timer checking for a change in child controls. I disable the timer when the control is in usermode.
I tried the SetParent and it blew up in design mode. Works fine in run mode though.
I am also experimenting with adding Frame2 to the VBE when the control first initializes to see if that will help. Then I can simply reject any controls that are dropped outside the frame2. This is proving to be harder than expected though.
I am trying to do it at design time.
Control11 is all compiled and ready.
Form1 is in design mode.
I am having some success with a timer checking for a change in child controls. I disable the timer when the control is in usermode.
I tried the SetParent and it blew up in design mode. Works fine in run mode though.
I am also experimenting with adding Frame2 to the VBE when the control first initializes to see if that will help. Then I can simply reject any controls that are dropped outside the frame2. This is proving to be harder than expected though.
ASKER
Apperently from all the documents I have read so far, it is not posible to do what I am looking for. There is no code method to add or remove or change the parent/child relations of contained controls within a control. A little frustrating, but I will live.
I have a couple other ways to make this project work. I will just make the two sections completely different controls and use them together
I have a couple other ways to make this project work. I will just make the two sections completely different controls and use them together
ASKER
Not the answer I was looking for but since it proved useful for something else I am crediting it.
Dim t As Textbox
Set t = Me.Controls.Add("VB.Textbo
With t
.Visible = True
.Top = 100
.Left = 100
.Text = "Here I Am"
End With