开发者

Desktop applications dynamic GUI problem

开发者 https://www.devze.com 2022-12-18 06:07 出处:网络
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 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 proje开发者_Go百科ct 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消