列出项目中的所有表单 [英] List All Forms In Project

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

问题描述

我希望能够列出项目中的所有表单,并且还可以使用其中的控件进行操作。我创建如下代码:

I want to be able to list all forms in the project and also to manipulate with controls within them. I genereate the code as below:

Dim MainAssembly As System.Reflection.Assembly
Dim cWinForm As System.Type
Dim WinType As Type
Dim WinTypes() As 类型
MainAssembly = System.Reflection.Assembly.GetExecutingAssembly
cWinForm =
GetType ( System.Windows.Forms.Form)
WinTypes = MainAssembly.GetTypes
For 每个 WinType In WinTypes
If WinType.GetType cWinForm.GetType 然后 < br> MsgBox(WinType.Name)
结束 如果
Next

Dim MainAssembly As System.Reflection.Assembly
Dim cWinForm As System.Type
Dim WinType As Type
Dim WinTypes() As Type
MainAssembly = System.Reflection.Assembly.GetExecutingAssembly
cWinForm =
GetType(System.Windows.Forms.Form)
WinTypes = MainAssembly.GetTypes
For Each WinType In WinTypes
If WinType.GetType Is cWinForm.GetType Then
MsgBox(WinType.Name)
End If
Next

但上面的代码只给出了所有项目表单的类型。我希望能够访问这些表单,但我不知道如何。有人可以帮帮我吗?

问候,

推荐答案

以下是否有帮助?

Does the following help?

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=82486&SiteID=1

然后,对于每个表单,都有一个控件可以访问的集合属性。

Then, for each form, there is a Controls collection property that can be accessed.


这篇关于列出项目中的所有表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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