Iterate through all forms in a project...


Author
Message
StarkMike
StarkMike
Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)Advanced StrataFrame User (738 reputation)
Group: Forum Members
Posts: 436, Visits: 944
I can't seem to find out how to iterate through all the forms in a VB project. Why does this seem so difficult to do? I'm aware of the OpenForms property but I cant really open ALL the forms in my project just to iterate through them.



I can even find out how to reference a form if i have the name:

dim frm as form = Forms("Form1")



Anybody got any advice?
Reply
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Guys,

This may (or not) help but we use DevExpress and I wanted a generic front end to all our DeVExpress reports that collects the data selection criteria for each report then instantiates the report and I didn't want to hard code anything. The starting point for this was to be able to find all DevExpress reports in a Solution. I couldn't figure out how to do this so I asked DevExpress support who supplied the following code.


    Private Sub CreateReportInstance(ByVal ReportName As String, ByRef Report As DevExpress.XtraReports.UI.XtraReport)

        Dim asm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()

        ' Find all reports and assign the instance of the report name we are looking for
        For Each type As Type In asm.GetTypes()
            If type.IsSubclassOf(GetType(DevExpress.XtraReports.UI.XtraReport)) Then
                If (type.Name = ReportName) Then
                    Dim myReport As DevExpress.XtraReports.UI.XtraReport = CType(Activator.CreateInstance(type, False), DevExpress.XtraReports.UI.XtraReport)
                    Report = myReport
                    Exit For
                End If
            End If
        Next type
    End Sub


BTW - DevExpress and StrataFrame offer the best support it has ever been my pleasure to come across.

Cheers, Peter

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search