get all form details in vb.net

2019-09-20 17:09发布

i want list all forms in current project. example listbox1.items.add(form1.name & form1.text)

i want load all form details in current project.

the following code give for only open forms.

  For linti As Integer = Application.OpenForms.Count - 1 To 0 Step -1
      Application.OpenForms.Item(linti).Text
      Application.OpenForms.Item(linti).name
  Next

i want all form and its text. what i do sir please help me

标签: vb.net forms
1条回答
家丑人穷心不美
2楼-- · 2019-09-20 17:36

Using a bit of Linq you could try

Dim list = AppDomain.CurrentDomain.GetAssemblies().ToList(). _
                    SelectMany(Function(s) s.GetTypes()). _
                    Where(Function(p) (p.BaseType Is [GetType]().BaseType AndAlso _
                                       p.Assembly Is [GetType]().Assembly))
For Each type As Type In list
    Dim typeName As String = type.Name
Next
查看更多
登录 后发表回答