简体   繁体   English

在解决方案资源管理器中查找活动winform

[英]Find active winform in solution explorer

I started working on a existing solution that has a very large number of Winforms. 我开始研究具有大量Winforms的现有解决方案。 Is there a quick way to find the design time form, in the Visual Studio Solution Explorer, when the application is running? 在应用程序运行时,是否可以在Visual Studio解决方案资源管理器中快速找到设计时间表单?

Please note: debug/break will only help me find modal forms (dialogs). 请注意:debug / break只能帮助我找到模态表单(对话框)。 I am interested in finding modeless winforms too. 我也有兴趣找到无模式的winforms。 I don't consider plowing through design time menus and events as a quick way.. 我不认为快速浏览设计时菜单和事件。

I hope this is what you want: 我希望这是你想要的:

With Application.OpenForms ( click ) 使用Application.OpenForms( 单击

You'll get a list of all open Forms which belongs to you project. 您将获得属于您项目的所有打开表单的列表。 Then you can easily find out the form in the Explorer. 然后,您可以在资源管理器中轻松找到该表单。

You could also make an debug menu item on you main form and put in it : 您还可以在主窗体上创建一个调试菜单项并放入其中:

string test = string.Empty;
foreach (Form item in Application.OpenForms)
{
    test += item.GetType().ToString() + Environment.NewLine;
} 
MessageBox.Show(test);

This will give you a list of openforms just like Markus G suggested but without the need of creating a form for this. 这将为您提供一个开放表单列表,就像Markus G建议的那样,但不需要为此创建表单。

Also look at this : 还看看这个:

https://msdn.microsoft.com/en-us/library/system.windows.forms.form.activeform(v=vs.110).aspx https://msdn.microsoft.com/en-us/library/system.windows.forms.form.activeform(v=vs.110).aspx

It explains how you can identify the active form, but as usual microsoft has made things a bit complex by having 2 methods, one for mdi forms and one for none mdi forms 它解释了如何识别活动表单,但像往常一样,microsoft通过使用2个方法使一些事情变得复杂,一个用于mdi表单,一个用于mdi表单

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM