Click here to Skip to main content
15,908,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm Trying to to make a form where it contains labels and textboxes and the contents are from the Datagridview also displayed in the form
now i'm trying to load the crstalreportviewer but from another form.
like i have a button in form 1 that when clicked it will show the crystal report viewer from form 2.

i have a code that loads the crystal report successfully but only from the same form.

any modications you can suggest i can do? or include in my code?
Thanks!

What I have tried:

Dim CRYRPT As New ReportDocument
        Dim CRTABLELOGONINFOS As New TableLogOnInfos
        Dim CRTABLELOGONINFO As New TableLogOnInfo
        Dim CRCONNECTIONINFO As New ConnectionInfo
        Dim CRTABLES As Tables
        Dim CRTABLE As Table

        CRYRPT.Load("C:\Practice\usb ko\pfiles\back up system\FinalProject\FinalProject\CRYSTALREPORT1.rpt")
            
        With CRCONNECTIONINFO
            .ServerName = "YOUR SERVER NAME"
            .DatabaseName = "YOUR DATABASE NAME"
            .UserID = "YOUR DATABASE USERNAME"
            .Password = "YOUR DATABASE PASSWORD"
        End With

        CRTABLES = CRYRPT.Database.Tables
        For Each CRTABLE In CRTABLES
            CRTABLELOGONINFO = CRTABLE.LogOnInfo
            CRTABLELOGONINFO.ConnectionInfo = CRCONNECTIONINFO
            CRTABLE.ApplyLogOnInfo(CRTABLELOGONINFO)
        Next

        CrystalReportViewer1.ReportSource = CRYRPT
        CrystalReportViewer1.Refresh()
Posted
Updated 4-Jul-21 16:33pm
v2

Have a read of OriginalGriff's series of Tips on communicating between forms in Windows Forms. Transferring information between two forms, Part 1: Parent to Child[^]
There are links to the other two in each Part.
The examples are in C# but they should be easy enough to follow with the description
 
Share this answer
 
i Have used this code and its working


With dt
           .Columns.Add("Schoolname")
           .Columns.Add("KM")
           .Columns.Add("KF")
           .Columns.Add("KT")
           .Columns.Add("G1M")
           .Columns.Add("G1F")
           .Columns.Add("G1T")
           .Columns.Add("G2M")
           .Columns.Add("G2F")
           .Columns.Add("G2T")
           .Columns.Add("G3M")
           .Columns.Add("G3F")
           .Columns.Add("G3T")
           .Columns.Add("G4M")
           .Columns.Add("G4F")
           .Columns.Add("G4T")
           .Columns.Add("G5M")
           .Columns.Add("G5F")
           .Columns.Add("G5T")
           .Columns.Add("G6M")
           .Columns.Add("G6F")
           .Columns.Add("G6T")
           .Columns.Add("ESTOTAL")
           .Columns.Add("SY")

       End With

       For Each dgr As DataGridViewRow In Me.ElementaryDataGridView.Rows
           dt.Rows.Add(dgr.Cells(0).Value, dgr.Cells(1).Value, dgr.Cells(2).Value, dgr.Cells(3).Value, dgr.Cells(4).Value, dgr.Cells(5).Value, dgr.Cells(6).Value, dgr.Cells(7).Value, dgr.Cells(8).Value, dgr.Cells(9).Value, dgr.Cells(10).Value, dgr.Cells(11).Value, dgr.Cells(12).Value, dgr.Cells(13).Value, dgr.Cells(14).Value, dgr.Cells(15).Value, dgr.Cells(16).Value, dgr.Cells(17).Value, dgr.Cells(18).Value, dgr.Cells(19).Value, dgr.Cells(20).Value, dgr.Cells(21).Value, dgr.Cells(22).Value, dgr.Cells(23).Value)

       Next




       Dim ReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument
       ReportDocument = New CrystalReport1
       ReportDocument.SetDataSource(dt)
       Generate_Elem.CrystalReportViewer1.ReportSource = ReportDocument
       Generate_Elem.ShowDialog()
       Generate_Elem.Dispose()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900