Jump to content

[Resolvido] Lista de todos os formulários


obamaself
 Share

Recommended Posts

Boas, existe maneira de ter a Tag de todos os formulários do meu projeto?

O código que utilizo para ver a lista te todos os formulários:

Dim Forms As New List(Of String)()
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
			Forms.Add(t.Name)
		End If
	Next

Aqui consigo apenas o nome, não consigo obter a Tag deles

Link to comment
Share on other sites

olá,

achei este code... deve servir

        Dim allForms() As Form = (From t As Type In Me.GetType().Assembly.GetTypes() _
                                        Where t.BaseType Is GetType(Form) _
                                        Let f = DirectCast(Activator.CreateInstance(t), Form) _
                                        Select f).ToArray

       For Each f As Form In allForms
           MsgBox(f.Tag)
       Next
Edited by thoga31
GeSHi
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.