Results 1 to 6 of 6

Thread: While in DesignMode drag Item on Control and then Programmatically add another.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2021
    Posts
    16

    While in DesignMode drag Item on Control and then Programmatically add another.

    I have a Control, inheriting a Panel.
    Programmatically I can add another Control as its child, and have the Parent add one more child, and change their size to fit its container.
    Now I'm trying to do the same in DesignTime: Dragging a Control on my Control and have the Parent add another child.
    I have used onControlAdded to react to the drop, which adds an other Control as it should.
    But, their size doesn't change, it stays the defaultsize.
    Plus, I can see the dropped Control in View and in the PropertiesBox, but not the programmatically create one.
    I don't add an example code, because I suspect the problem is more fundamental.
    (the whole approach probably)
    But if it would help?

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Jun 2021
    Posts
    16

    Re: While in DesignMode drag Item on Control and then Programmatically add another.

    Just to zoom in on my more fundamental misunderstanding:
    Is it at all possible for a (user)control to tell the designer it has changed the size or position of its children?
    Last edited by Black Monkey; Jun 16th, 2021 at 07:28 AM. Reason: enradable

  3. #3
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: While in DesignMode drag Item on Control and then Programmatically add another.

    Hi Black Monkey,

    Maybe it would help if you were to explain what you're trying to achieve rather than how you're trying to do it.


    Poppa
    Along with the sunshine there has to be a little rain sometime.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: While in DesignMode drag Item on Control and then Programmatically add another.

    Quote Originally Posted by Black Monkey View Post
    Just to zoom in on my more fundamental misunderstanding:
    Is it at all possible for a (user)control to tell the designer it has changed the size or position of its children?
    Custom Events and RaiseEvent

    (In your custom control)

    Code:
    Class MyControl
    
        Public Event MyEvent(ByVal AParameterIWantToSend As TheTypeOfThisParameter, ByVal AnotherParmeter As AnotherType, ...)
    
        ...
    
    End Class
    In the Resize or Move event of one of your custom control's child control...

    Code:
    RaiseEvent MyEvent(arg1, arg2, etc)
    In your Form...

    Code:
    Public Sub MyControl_MyEvent(ByVal AParameterIWantToSend As TheTypeOfThisParameter, ByVal AnotherParmeter As AnotherType, ...) Handles MyControl.MyEvent
        'put your 'what to do' on resize or move code here
    End Sub

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2021
    Posts
    16

    Re: While in DesignMode drag Item on Control and then Programmatically add another.

    @.paul.
    Reading back my original question, I think I had better taken an other cup of coffee before posting.
    Your code works like a charm, but I meant to ask how (if) a control can relay to a custom designer; that a child has been added, or the control has changed a property of its child.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2021
    Posts
    16

    Re: While in DesignMode drag Item on Control and then Programmatically add another.

    @Poppa Mintin
    My goal is; to create a control( parented to a Panel) that, in design-Mode,
    when a user drags an item onto it, creates an other item and adds that also as a child.
    So, drag (for instance) a panel on the control, and the result will be that the control has two panels as children.
    I can code that. But the custom designer, I have added to the control,( so the user can choose some properties of the added item( by smart-tags)), does not notice the second created item.
    I could have the user just add two items, but that doesn't feel intuitive.

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