Dynamic views

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jesper DK

    #1

    Dynamic views

    Thanks Noah

    Could you clarify point 1. Provide a link to a sample
    perhaps. I would like to learn to do it right.

    Another thing. If I dont drag my control to the form,
    what steps do I need to take in order for my form to be
    able to see the dll of the control

    Thanks and best regards.
    Jesper
    [color=blue]
    >-----Original Message-----
    >Hey Jesper,
    >
    >I do this exact same thing in several of my programs.[/color]
    There is a list of[color=blue]
    >'commands', each has its own GUI interface so there is a[/color]
    spot where the[color=blue]
    >correct control plugs in. Here are some things to[/color]
    consider:[color=blue]
    >
    >1. It would be a good idea, but not required, to make[/color]
    one UserControl[color=blue]
    >control that is a basic version of the plug-in control.[/color]
    Then the specific[color=blue]
    >plug-ins can all be extended from your 'template'[/color]
    instead of UserControl.[color=blue]
    >This gives you more control over how they look and[/color]
    interact.[color=blue]
    >
    >2. Yes, put a panel where you want the controls to go,[/color]
    it makes things a[color=blue]
    >little easier. Let's call it 'pnlHost'. All you really[/color]
    need to do is look[color=blue]
    >at the Windows Designer Generate Code to see how[/color]
    controls are added via[color=blue]
    >code. I'll give you what you need here.
    >
    >private void ShowControl(Use rControl c)
    >{
    > pnlHost.Control s.Clear(); // Remove any current[/color]
    controls in the panel[color=blue]
    > pnlHost.Control s.Add(c); // Put the special[/color]
    control in the host panel[color=blue]
    > c.Dock = DockStyle.Fill; // Make the control fill[/color]
    the host panel[color=blue]
    >}
    >
    >Then say you have a custom control[/color]
    called "PageSettin gs", you want to show[color=blue]
    >it in the host panel, just call: ShowControl(new[/color]
    PageSettings()) ;[color=blue]
    >
    >That's practically all there is to it!
    >
    >Good luck!
    >
    >-Noah Coad
    > Microsoft MVP & MCP [.NET/C#]
    >
    >
    >
    >"Jesper DK" wrote in message
    >news:033a01c35 7a6$9d3a57e0$a5 01280a@phx.gbl. ..[color=green]
    >> Hi,
    >>
    >> I'm writing a windows explorer like application. The[/color][/color]
    GUI[color=blue][color=green]
    >> is divided by a vertical splitter. To the left I have a
    >> tree control. To the right of the splitter I would like
    >> to display one of several different user controls
    >> according to what is selected in the tree control.[/color][/color]
    Now, I[color=blue][color=green]
    >> can do this by placing all of my different user[/color][/color]
    controls[color=blue][color=green]
    >> on the form and then use .Show() and .Hide() on the
    >> controls. However, I do not fancy this technique, Isn't
    >> there a more elegant way of doing this.
    >>
    >> Another thing, If I instantiate these user controls
    >> dynamically and place them on the form, should they be
    >> placed on a panel?. Where should I store the reference[/color][/color]
    to[color=blue][color=green]
    >> the user control.
    >>
    >> Thank you in advance.
    >> Best regards Jesper.[/color]
    >
    >
    >.
    >[/color]
    ..


Working...