C#WinForms应用程序打开第二个WinForms应用程序 [英] C# Winforms Application To Open a Second Winforms Application

查看:226
本文介绍了C#WinForms应用程序打开第二个WinForms应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我写了需要使用/纳入约6大块的小应用。理想我希望能够打开每个独立的应用程序这一块更小,而不是将代码添加到每一个。这将允许在事件易于维护也有他们只需要发生在一个应用程序的更改。

I have an small application that I have written that needs to be used/incorporated into about 6 larger pieces. Ideally I want to be able to open this smaller piece from each stand-alone application instead of adding the code to each one. This would allow for easier maintenance in the event there are changes they only need to take place in one application.

我已经看了,但我似乎无法弄清楚如何我可以从一个内部打开第二个WinForm应用程序。任何帮助将是巨大的。

I have looked but I can't seem to figure out how I can open a second winform application from inside of one. Any help would be great.

感谢

推荐答案

2的选项。

1)如果这个小的应用程序可以单独存在,这意味着它可以在一些有用的方式执行,而不由父应用正在催生,然后用过程。开始()。您的应用程序(s)表示,产卵这个过程可能无法在部分信任的环境中运行。

1) If this small app can stand alone, meaning it can execute in some useful fashion without being spawned by a parent app, then use Process.Start(). Your application(s) that spawn this process may not be able to run in a partial-trust environment.

Process.Start("notepad.exe");



2)如果应用程序仅是父应用程序的范围内是有用的,由被赋予对象说或从其他应用其他参数,考虑重构的小的应用程序,使窗体的项目,由父应用程序中引用。然后,你的父母应用程序可以简单地创建窗体的新实例,并显示它:

2) If the app is only useful within the context of the parent apps, say by being given objects or other arguments from the other apps, consider refactoring the small app to allow the form's project to be referenced by the parent apps. Then, your parent apps can simply create a new instance of the form and display it:

var childForm = new SmallAppForm();
childForm.Owner = this; //the child window will close when its owner does.
childForm.Show();



虽然它是更多的代码,它通常是更方便,更简单的实现。该表格也可访问,从而从其他应用程序的控制和其他功能可以在无需处理跨进程通信的相当混乱的业务来实现。

Though it's more code, it's generally easier and more foolproof to implement. The form can also be accessed and thus controlled from elsewhere in the app, and other functionality can be implemented without having to deal with the rather messy business of cross-process communication.

这篇关于C#WinForms应用程序打开第二个WinForms应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆