views:

142

answers:

1

I am embedding usercontrols in a panel and using DevExpress Navigator control to navigate from one to the other. What I am concered about is any implications to this method?

I would give examples of what I am concerned about but then I wouldn't need to ask this question...

I have a primary form, ShellForm that has a docked Navigator Control on the left and a docked Panel Control for the rest. I then dock a User Control, say ucSearchPage, in the Panel when the link is clicked.

    public partial class ShellForm : XtraForm
{
    private ucSearch searchPage = new ucSearch();
    private ucEnrollments enrollmentPage = new ucEnrollments();
    private ucGeneral generalInfoPage = new ucGeneral();
    private ucContacts contactPage = new ucContacts();

    public ShellForm()
    {
        InitializeComponent();
    }

    private void ShellForm_Load(object sender, EventArgs e)
    {
        this.pnlShellHost.DockControl(this.searchPage);
    }

    private void navSearch_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
    {
        this.pnlShellHost.DockControl(this.searchPage);
    }

    private void navEnrollment_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
    {
        this.pnlShellHost.DockControl(this.enrollmentPage);
    }

The code for DockControl() is as follows -->

        public static void DockControl(this Control control, UserControl userControl)
    {
        userControl.Dock = DockStyle.Fill;
        control.Controls.Clear();
        control.Controls.Add(userControl);
    }

Are there any implications to this approach? Is it just plan stupid?

I am one of those programmers that had to learn to run before walking so I have a tendency to fall flat on my face!

There will be about 30 User Controls in all.

Any insight is welcomed and appreciated!

+3  A: 

IMO it is not a bad idea at all to embed user controls. In fact, that is exactly what they were meant for. Because every control inherits from the same base class you can build a tree structure of controls using the Composite pattern. This will allow you to create just about anything you would like.

If you think of a basic web page, this is actually what you are doing anyways: placing one element in another, or embedding them. You can have multiple divs in other divs etc. This is essentially what you are doing when you embed user controls as the user controls render to basic HTML.

Hope this helps.

EDIT: To address the concerns in your comment... I don't think you will have a problem from the data entry standpoint. The reason why is because you are using different user controls for your enrollment control and search control. I'm assuming you are overriding the OnLoad event in each of those user controls right? What happens on post back is that the Search's OnLoad will be hit if the search control was loaded, while the enrollment's OnLoad will be hit if that was loaded.

Because of the polymorphism of the user controls, you can handle the data for those controls separately.

Polaris878
From a Data Entry point do you see a problem? I would have users searching on one "page" and it would have to fill in fields on another "page". There would never be more then 1 instance of a page so declaring them like I am....would I be fine???? Thanks!
Refracted Paladin
Paladin, read my edit see if that makes sense.
Polaris878