How to select a control within a control in design-time?

Hi,

I am building a custom control that mimics the MS's outlook bar. It consisits of a panel, which has bands and each band has a button that serves as a caption of the band and a container panel within the band.

My question is:
In design-time, how can I select that container panel, which lies within the band panel
I read all about the ParentControlDesigner class but didn't find anything (may be I am missing the point )
Any suggestion is appreciated!

Thanks,
Gogou


Answer this question

How to select a control within a control in design-time?

  • Brian Travis

    Nice.. that is a cool way to do that..
    Is there a way to then add child controls to the ColourButton Component or would one have to go in a different direction and not Inherit the component object for the ColourButton Class

  • ccoxon

    Hello Gogou,
    You may want to try this: Designers offer a useful method to override, called GetHitTest. This is passed some coordinates, and it's up to your logic to let the designer know whether or not to pass the event (usually a click) on to the control underneath. You can override this method, and see if the mouse cursor is within the bounds of any of the controls on the control you are designing. If it is, then return true. Override OnMouseDown() method and in it check if we are in DesignMode. If so, then use ISelectionService to set selection on the inner panel using SetSelectedComponents methods.

    For more information see: http://www.divil.co.uk/net/articles/designers/collectioncontrols.asp 

    Thanks,
    -Dinesh Chandnani 

  • rwbogosian

    I don't really know what you mean, because the user could select the container panel just by clicking on it. If you mean programmatically selecting the panel, then look into the ISelectionService interface. For example:

    ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService));

    selectionService .SetSelectedComponents(new object[] {ContainerPanelToSelect});

    Also, the component you are trying to build has already been build several times. I sugest that you download such a implementation and check the source for pointers.

    Regards,

    Paul

  • extraT

    Hi, Jantie

    Thanks for your reply.

    In fact I already tried that - the Control property of the ParentControlDesigner class is virtual, so it might be overriden. In the WndProc I catch the WM_LBUTTONDOWN message and hittest to get the underlying control and then througn the Control property I return that control. But it is not working correctly:(( I also override the AssociatedComponents property to add the inner panel but it also does not behaves properly. If you have already written some code on that and it is working please let me see it!

    Thanks,
    Gogou

  • Azeem Fraz

    I have a tab control with in a user control. I'm adding this user control to a form. When i add a control to this form,  i want to make first tab as the parent. How do i do this  or I would like to select the tab control and add one more tab
  • dor

    Hi, Dinesh,

    Thanks alot for your reply!
    That is what I was looking for:)

    Actually I was missing that overriding the panel's OnMouseDown will work also when in design mode!

    Regards,
    Gogou

  • Celtic_Guy

    Just make a property of the Control type:


    Public Property Control() As Control
        Get
            Return _control
        End Get
        Set(ByVal Value As Control)
            _control = Value
        End Set
    End Property


    Let me know if this is not what you were looking for!

    Jan

  • How to select a control within a control in design-time?