Results 1 to 5 of 5

Thread: Change .Container dinamically

  1. #1

    Thread Starter
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    198

    Question Change .Container dinamically

    Hi guys! Im developing a Custom Control (a form scroller) where it present scrollbars and allow to scroll the controls wich are inside a picturebox.
    When I put my custom control on a form it allow to be used as a Container, but the problem is that every control I add is bound to the Usercontrol and not to the picturebox that scroll inside.
    I tried changing the container of the added objects to the picturebox with this code:

    Code:
        Dim o As Object
        For Each o In UserControl.ContainedControls
            Set o.Container = picPicture
        Next
    but that dosn't seem to work. Any ideas if its posible ?

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: Change .Container dinamically

    It is not possible.
    You can't change the container of a control that its parent is a Form to a container inside an UserControl (you would need to change the Parent).
    In the past I've tried with the API SetParent but it worked with problems.

    Here I just posted a control that does that but changing the position of each individual control.

  3. #3

    Thread Starter
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    198

    Re: Change .Container dinamically

    Thanks you Eduardo! Seems your control does exactly what I was doing. (wanted scroll to be able to be used in desing mode)
    With your permision I want to use is as the base of my control. (I will port a few things from my control like .top,.left and an event when user scrolled it to the bottom)

  4. #4

    Thread Starter
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    198

    Thumbs up Re: Change .Container dinamically

    Thanks you Eduardo! Seems your control does exactly what I was doing. (wanted scroll to be able to be used in desing mode)
    With your permision I want to use is as the base of my control. (I will port a few things from my control like .top,.left and an event when user scrolled it to the bottom)

  5. #5
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: Change .Container dinamically

    Quote Originally Posted by shagratt View Post
    Thanks you Eduardo! Seems your control does exactly what I was doing. (wanted scroll to be able to be used in desing mode)
    With your permision I want to use is as the base of my control. (I will port a few things from my control like .top,.left and an event when user scrolled it to the bottom)
    Yes, of course, you can use it as you want.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width