#Region "프로젝트 폼 목록 읽어 오기..."
'프로젝트 내 폼 찾기...
Public Shared Function GetAssemblyForm(ByVal strFormName As String) As Form
Dim f As Form = Nothing
For Each t As Type In System.Reflection.Assembly.GetExecutingAssembly().GetTypes()
If (t.Name = strFormName) Then '찾을려는 폼 이름과 같으면....
Dim o As Object = Activator.CreateInstance(t) '새로운 인스턴스 개체 생성...
f = CType(o, Form) '개체를 Form 개체로 변환...
Exit For
End If
Next
Return f '찾았는 폼 개체 반환 Nothing 이면 못찾음 아니면 찾음
End Function
'프로젝트 내 폼 리스트 반환...
Public Shared Function GetAssemblyFormList() As List(Of Form)
Dim ltForm As List(Of Form) = New List(Of Form)
For Each t As Type In System.Reflection.Assembly.GetExecutingAssembly().GetTypes()
If (t.BaseType.FullName.ToString() = "System.Windows.Forms.Form") Then ' 개체 타입이 Form 이면...
Dim o As Object = Activator.CreateInstance(t) '새로운 인스턴스 개체 생성...
Dim f As Form = CType(o, Form) '개체를 Form 개체로 변환...
ltForm.Add(f) '리스트변수에 찾은 Form 개체 담기...
End If
Next
Return ltForm '폼 리스트 반환...
End Function
#End Region
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ltList As List(Of Form) = GetAssemblyFormList()
For iCount As Integer = 0 To ltList.Count - 1
Dim f As Form = CType(ltList(iCount), Form)
ListBox1.Items.Add(f.Text)
Next
End Sub
Public Shared Function GetAssemblyForm(ByVal strFormName As String) As Form
Dim f As Form = Nothing
For Each t As Type In System.Reflection.Assembly.GetExecutingAssembly().GetTypes()
If (t.Name = strFormName) Then
Dim o As Object = Activator.CreateInstance(t)
f = CType(o, Form)
Exit For
End If
Next
Return f
End Function
Public Shared Function GetAssemblyFormList() As List(Of Form)
Dim ltForm As List(Of Form) = New List(Of Form)
For Each t As Type In System.Reflection.Assembly.GetExecutingAssembly().GetTypes()
If (t.BaseType.FullName.ToString() = "System.Windows.Forms.Form") Then
Dim o As Object = Activator.CreateInstance(t)
Dim f As Form = CType(o, Form)
ltForm.Add(f)
End If
Next
Return ltForm
End Function
End Class
'VB.NET Programming' 카테고리의 다른 글
[VBNET] BackGround Worker 를 이용 백그라운드 스레드 (0) | 2019.09.17 |
---|---|
[VBNET] 크로스 스레드 (Cross Thread) 예제 (0) | 2019.09.16 |
[VBNET] 델리 게이트 (Delegate) - 델리게이트란? , 선언 방법과 간단한 예제 (0) | 2019.09.13 |
[VBNET] 컨트롤 배열처럼 사용 하기(Controls Arrary) (0) | 2019.09.03 |
[VBNET] 시간 체크 함수 (Time Check Func) (0) | 2019.09.02 |