-
Jul 24th, 2024, 11:27 AM
#1
Thread Starter
Fanatic Member
How do I set the Container property of a control?
Short version of the question:
How do I set the Container property of a tB control (text box)?
Context:
I've got an array of tB text boxes which I create dynamically at runtime from a single initial textbox already on a form. The text boxes are within containers - frames to be exact. There's two different frames with some of the text boxes in the first frame and some in the second frame (meaning not all of the textboxes in the control array have the same container). I need to be able to set the container of the dynamically created text boxes so that they'll appear within the correct frame. But when I try to set the Container property of the new textbox, I get a 438 error (Object doesn't support this property or Method). How do I set this value?
If I don't try to specify a Container, the new dynamically created text boxes appear in the first frame while I want them to appear in the second frame. So it appears that the assumption being made in the underlying code is that all elements of a control array will all share the same container. As my situation shows, that's not a correct assumption to make and should allow developer override.
The code is pretty straightforward and works in VB6 so don't think it's a coding error:
Code:
' Find the next index
Dim NewIndex As Integer
NewIndex = txtOrderDetail.UBound + 1
' Load the new text box
Load txtOrderDetail(NewIndex)
' Set the container for the new control
Set txtOrderDetail(NewIndex).Container = poContainer
' make it visible
txtOrderDetail(NewIndex).Visible = True
I've looked at the definition for the Container property and it seems to be read-only (there's a Get but no Set/Let)
Code:
Public Property Get Container() As Object
On Error Resume Next
EnsureFormIsLoaded()
Return Me.RootWindowElementBase.Container
End Property
I've followed the definitions back to the WindowsControls.twin file, _WindowElement interface and there's only a Get Container so this seems to go all the way back to the element base class. This class is not editable or else I'd try to resolve this myself by adding a Set version of this.
I believe this is an oversight or perhaps not and just hasn't been implemented yet?
Last edited by AAraya; Jul 24th, 2024 at 12:22 PM.
-
Jul 24th, 2024, 12:08 PM
#2
Re: How do I set the Container property of a control?
Originally Posted by AAraya
Short version of the question:
How do I set the Container property of a tB control (text box)?
Context:
I've got an array of tB text boxes which I create dynamically at runtime from a single initial textbox already on a form. The text boxes are within containers - frames to be exact. There's two different frames with some of the text boxes in the first frame and some in the second frame (meaning not all of the textboxes in the control array have the same container). I need to be able to set the container of the dynamically created text boxes so that they'll appear within the correct frame. But when I try to set the Container property of the new textbox, I get a 438 error (Object doesn't support this property or Method). How do I set this value?
The code is pretty straightforward and works in VB6 so don't think it's a coding error:
Code:
' Find the next index
Dim NewIndex As Integer
NewIndex = txtOrderDetail.UBound + 1
' Load the new text box
Load txtOrderDetail(NewIndex)
' Set the container for the new control
Set txtOrderDetail(NewIndex).Container = poContainer
' make it visible
txtOrderDetail(NewIndex).Visible = True
I've looked at the definition for the Container property and it seems to be read-only (there's a Get but no Set/Let)
Code:
Public Property Get Container() As Object
On Error Resume Next
EnsureFormIsLoaded()
Return Me.RootWindowElementBase.Container
End Property
I've followed the definitions back to the WindowsControls.twin file, _WindowElement interface and there's only a Get Container so this seems to go all the way back to the element base class. This class is not editable or else I'd try to resolve this myself by adding a Set version of this.
I believe this is an oversight or perhaps not and just hasn't been implemented yet?
Not implemented yet, sorry. @sokinkeso had mentioned it over on discord some time ago, so it is known, and we'll get to it soon.
-
Jul 24th, 2024, 12:23 PM
#3
Thread Starter
Fanatic Member
Re: How do I set the Container property of a control?
OK, glad to know it's already been mentioned.
-
Jul 28th, 2024, 11:22 AM
#4
Re: How do I set the Container property of a control?
-
Jul 29th, 2024, 08:56 AM
#5
Thread Starter
Fanatic Member
Re: How do I set the Container property of a control?
Originally Posted by xiaoyao
can use api,setparent
[Edit] - Deleted as the info I posted was wrong!
Last edited by AAraya; Jul 29th, 2024 at 10:18 AM.
-
Jul 29th, 2024, 09:53 AM
#6
Re: How do I set the Container property of a control?
VB6 (and tB) Frame controls have .hwnd
-
Jul 29th, 2024, 10:09 AM
#7
Thread Starter
Fanatic Member
Re: How do I set the Container property of a control?
Last edited by AAraya; Aug 1st, 2024 at 09:08 AM.
-
Jul 29th, 2024, 10:14 AM
#8
Thread Starter
Fanatic Member
Re: How do I set the Container property of a control?
Too weird - now it works just fine with no error. Issue resolved - the controls now appear in the correct containers!
Thanks xiaoyao and fafalone!
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
|