简体   繁体   中英

Find active winform in solution explorer

I started working on a existing solution that has a very large number of Winforms. Is there a quick way to find the design time form, in the Visual Studio Solution Explorer, when the application is running?

Please note: debug/break will only help me find modal forms (dialogs). I am interested in finding modeless winforms too. 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 )

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.

Also look at this :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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