如何在数组中获取 VB.net (VS08) 项目中的所有表单? [英] How to get all forms in a VB.net (VS08) project in an array?
本文介绍了如何在数组中获取 VB.net (VS08) 项目中的所有表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,所以我需要一个方法来遍历 Visual Studio 2008 下的 VB.net 项目中的所有表单,并创建一个类型为 form 的数组,并引用其中的所有表单,使数组看起来像这样(伪代码)
Alright, so I need a method that traverses all the forms inside a VB.net project under Visual Studio 2008, and create an array of type form with references to all the forms inside it, so that the array looks like this (pseudocode)
FormsArray() = [Form1, Form2, Form3, Form4]
但是,我不知道如何开始.
However, I don't have a clue as to how to begin.
推荐答案
你必须调整函数把msgbox
的结果放入数组
You have to adjust the function to put the result of msgbox
in a array
Public Sub getallforms(ByVal sender As Object)
Dim Forms As New List(Of Form)()
Dim formType As Type = Type.GetType("System.Windows.Forms.Form")
For Each t As Type In sender.GetType().Assembly.GetTypes()
If UCase(t.BaseType.ToString) = "SYSTEM.WINDOWS.FORMS.FORM" Then
MsgBox(t.Name)
End If
Next
End Sub
您必须像这样从应用程序中的任何表单调用该函数 (getallforms(me)
)
You must call the function from any form in the application like this (getallforms(me)
)
这篇关于如何在数组中获取 VB.net (VS08) 项目中的所有表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文