views:

178

answers:

2

Hi everyone,

I have asked the question "Is there something like master page in desktop applications?" Now I am in position that I have to extend the question. Thanks for understanding.

I have add one MDI master form into my project and several inherited forms that inherit MDI master one. I was using this code.

private void searchToolStripMenuItem_Click(object sender, EventArgs e)
{
    foreach (Form child in this.MdiChildren)
    {
       child.Close();
    }   

    Search childSearchForm = new Search();
    childSearchForm.MdiParent = this;
    childSearchForm.Text = "Search ";
    childSearchForm.Show();            
}

This code is triggered when I press some button on master form and the new in this case Search form is opened inside master.

Now my question is the right way to build desktop applications or there is some other more elegant way where content of user interface can be dynamic and switch from view to view by clicking on the buttons inside. For instance clicking on "Search" button on some search form will take you to search results grid, all that happening in one master form.

And if this is right way (which I doubt) how can I achieve to open other inside forms by clicking on buttons inside them. Also if I put some controls on masterpage they will appear two times in master form and in inherited form.

Thanks.

PS

I am using Visual Studio 2008 and MS SQL 2005.

A: 

Not sure how you would easily do this in winforms, but in WPF you could create a navigation app - a link driven navigation similar to a web browser experience but still a stand alone application. See http://msdn.microsoft.com/en-us/rampup/cc514215.aspx for details of how to get started.

burnside
+2  A: 

If you are only wanting to show one view at a time you could create a new user control for each view you require. e.g One for your search results.

Then you could add a panel and clear the controls contained within the panel and add the new one to display the view you are after.

Or as described, the other option is to use a tab control, hide the tabs and set the visible index programatically.

53an
If you only want one form, I would agree with 53an and build user controls to host all of your functionality.
Walter