循环使用解决方案中的所有表单 [英] Looping through all the forms in solution

查看:109
本文介绍了循环使用解决方案中的所有表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想遍历我的解决方案中存在的所有表单,以便将我的解决方案中存在的表单的名称以编程方式添加到哈希表中。我可以这样做吗?

I want to loop through all the forms present in my solution to add the name of the form present in my solution to a hashtable programatically.how can i do that?

推荐答案

解决方案不包含表单,不能循环。如果您有一个正在运行的表单应用程序,则可以使用 System.Windows.Forms.Application列出打开的表单。 .OpenForms ,请参阅 http://msdn.microsoft.com/ en-us / library / system.windows.forms.application.aspx [ ^ ]。



您还可以使用Reflection计算表单类。你需要吗?



从运行时的角度来看,没有解决方案。从解决方案的角度来看,没有Form这样的东西,只有一组项目文件有一组源文件。







如Firo所提议的解决方案是可行的,但它不能给你可靠的结果。您可以创建一个没有派生表单类的表单,您可以通过永远不使用它来创建表单类。鉴于此,您需要考虑哪些形式?如果一个表单类用于创建两个不同的表单,那么你想如何计算。



这一切对我来说没有任何意义。如果你解释所有这些的目的,你可能有机会得到更好的答案。



-SA
Solution does not consist of forms, no looping is possible. If you have a running form application, you can list the just the open forms using System.Windows.Forms.Application.OpenForms, see http://msdn.microsoft.com/en-us/library/system.windows.forms.application.aspx[^].

You can also count of form classes using Reflection. Do you need it?

From the run-time standpoint, there is no such thing as solution. From the standpoint of solution, there is no such thing as Form, there is just a set of project files which has a set of source files.



Solution as proposed as Firo is possible, but it cannot give you reliable result. You can create a form which has no derived form class, you can create a form class by never use it. In view of that, which exactly forms do you need to take into account? If one form class is used to created two different forms, how do you want to count.

All this does not make any sense to me. If you explain the purpose of all of that, you might have a chance to get a better answer.

—SA


这很复杂



我的建议是:

1.阅读.sln文件

2.找到这样的行:(使用RegEx)

This is quite complicated

My recommendation is:
1. Read the .sln file
2. Find some lines like this:(Use RegEx)
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MSK", "MSK\MSK.vbproj", "{0CD3E9B3-0340-43ED-9FAF-49E290122C30}"



3.查找.vbproj目录(MSK\MSK.vbproj)(使用RegEx)

4.阅读.vbproj文件

5.找到这样的行:(使用RegEx)


3. Find .vbproj directory ("MSK\MSK.vbproj") (Use RegEx)
4. Read .vbproj file
5. Find some lines like this:(Use RegEx)

<Compile Include="controller\Controller.vb" />






or

<Compile Include="frmBuatRealisasiPDJMan.Designer.vb">
      <DependentUpon>frmBuatRealisasiPDJMan.vb</DependentUpon>
    </Compile>



6.查找.vb文件的目录(使用RegEx)

7.查找来自.vb文件的类名(如有必要)(使用RegEx)

8.从点开始放任何你想要的东西6或7成哈希表

9.重复直到你得到你想要的一切。


6. Find directory of .vb files(Use RegEx)
7. Find class name (if necessary) from .vb files (Use RegEx)
8. Put anything you want from point 6 or 7 into hashtable
9. Repeat until you got everything you wanted.


看看 Application.OpenForms [ ^ ] property
Look at the Application.OpenForms[^] property


这篇关于循环使用解决方案中的所有表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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