Results 1 to 2 of 2

Thread: Creating Navigation User Control

  1. #1

    Thread Starter
    Fanatic Member Satal Keto's Avatar
    Join Date
    Dec 2005
    Location
    Me.Location
    Posts
    518

    Question Creating Navigation User Control

    Hello, I am currently trying to create a generic navigation control with a similar style to the outlook navigation bar. I have figured out how I would be able to dynamically create the bottom part where you select the menu option, but I'm struggling to figure out how I would be able to create the top part, which can contain any user control that the developer would want.

    So basically what I'm trying to figure out is, is there a way to allow for a developer to add controls to a specific area of your user control?

    If there is a way of achieving that then if anyone knows how to do this;
    In ASP.Net you have the login controls and with one of them, you are able to have different views depending on whether the user who is viewing the web page is logged in or not. Is there a way of achieving this in VB.Net for a user control that could be set up so that I could have the developer able to switch the view in the designer to show them the view for when a specific navigation option has been selected.

    The one thing that I have thought of that could possibly cause a problem is having the capability of knowing when one of the user controls has been clicked, while I haven't figured this out exactly, I believe I should be able to achieve this by having an event for the navigation user control that provides the developer a reference to the control.

    While I would hope that I have explained what I'm thinking well, its before my first coffee of the morning so I might have missed out some detail which would help someone to help me if I have then please let me know and I'll provide any details required.

    Also if what I'm envisioning is Pie in the sky, then let me know and I'll just have to make a base which I would just have to make a more bespoke system.

    Thanks for any help/suggestions/comments in advance.

    Satal

  2. #2
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: Creating Navigation User Control

    It can be quite complicated to allow a UserControl to accept controls (eg: behave as a parent control).

    The easiest case is when you want your whole UserControl to be able to accept controls (just like a Panel). You can specify a Designer attribute for your UserControl class and tell it to use the ParentControlDesigner. That's all you need to do; the rest is done automatically.

    However, this makes no sense for the control you are talking about, as obviously you want to be able to put a control in a specific panel, depending on which 'button' is selected. To do that, you must add the 'panels' (they can be actual Panels, or any other control that accepts controls) during design-time.

    Basically you need to use a DesignerHost object and its CreateComponent method to create a new panel object, which will then be enabled for design-time (unlike adding the panel in the UserControl designer, in which case it will be part of the UserControl and not have design-time enabled).

    It's not trivial but it can be done. For an example, see my WizardControl example. There's also other examples such as a VisualStudiosTabControl by ForumAccount I think. The idea is the same.

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