DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: loading a image at runtime in crystal reports XI

  1. #1
    Join Date
    Sep 2005
    Posts
    21

    loading a image at runtime in crystal reports XI

    Hi

    I am using crystal reports XL. In this I have to code in C# such that , it have
    to load a image at run time in crystal ReportXI . How to code it.
    Please help me to do this .

    Dhol

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    If you don't get an answer here, you might try Crystal's tech support site: http://support.businessobjects.com
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Sep 2005
    Posts
    21
    Hi

    I am using crystal reports XL. In this I have to code in C# such that , it have
    to load a image at run time in crystal ReportXI .

    I searched and I found a example of how to load a image at run time, whcih is given i n VB.NET...

    In that form employs with acrystal report viewer , a buttton (named loadimage)
    then, ther is a xsd file named dsImageReport.xsd
    the xsd file has 2 fieldnames i) "Name" type="xs:string"
    ii) "Photo" type="xs:base64Binary"

    and a crystal report is designed named rptImage.rpt......

    and the coding is done as follows


    this is the code inside button click
    Private Sub btnLoadImage_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles btnLoadImage.Click

    Dim ofdImage As New OpenFileDialog

    If ofdImage.ShowDialog = DialogResult.OK Then

    Try

    'Create a new instance of the dataset
    Dim dsImgRpt As New dsImageReport

    'Create a new instance of the report
    Dim m_imagereport As New rptImage

    'Create a new row in the dataset
    Dim dr As dsImageReport.ImageRow = _
    dsImgRpt.Image.NewImageRow

    'Set the various elements of the row
    dr.Name = ofdImage.FileName
    'fill this field with a byte array
    dr.Photo = GetImageData(ofdImage.FileName)

    'Add the new row to the dataset
    dsImgRpt.Image.Rows.Add(dr)

    'Use the dataset as datasource for the report
    m_imagereport.SetDataSource(dsImgRpt)

    'Show the report in the reportviewer
    Me.crystalReportViewer1.ReportSource = m_imagereport

    Catch ex As Exception

    MessageBox.Show("Something went wrong: " & ex.Message)

    End Try

    End If

    End Sub

    \\then some more coding as follows

    Private Function GetImageData(ByVal fileName As String) As Byte()

    'Method to load an image from disk and return it as a bytestream
    Dim fs As System.IO.FileStream = _
    New System.IO.FileStream(fileName, _
    System.IO.FileMode.Open, System.IO.FileAccess.Read)
    Dim br As System.IO.BinaryReader = New System.IO.BinaryReader(fs)
    Return (br.ReadBytes(Convert.ToInt32(br.BaseStream.Length)))

    End Function


    End Class
    now when compiled and run , we can able to load an image at runtime by clicking the load image button and selecting a image from the disk.then the at image is displayed in the report.

    I cant understand.... so please any one explain me the program and can anyone explain it in c#....
    ....

    dhol

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    You may use a tool like this one to translate the code from VB to C#: http://www.carlosag.net/Tools/CodeTranslator/
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Sep 2005
    Posts
    21

    pls help me out

    I tried phil, But i couldnt do... I dont know . I will attach that whole file done in vb as zipped document.Just run that form . u can find the output...please convert in c# and sent it to me..Please help me to do this...

    As only 100kb can be attched , i will sent the rpt file and xsd file in the next thread... just add those 2 files in the folder and do it .


    dhol
    Attached Files Attached Files

  6. #6
    Join Date
    Sep 2005
    Posts
    21

    continuation

    here is the report and xsd file attched in this thread.
    just extract this zip file and take those two files(rpt and xsd and add to the previous folder).
    please help me to do this.

    dhol
    Attached Files Attached Files

Similar Threads

  1. Working with Crystal Report Ver 10
    By AM003295 in forum VB Classic
    Replies: 4
    Last Post: 08-12-2005, 09:13 PM
  2. Compile Crystal Reports into an exe
    By Jeff123 in forum .NET
    Replies: 0
    Last Post: 06-30-2005, 07:51 AM
  3. wot is CLR
    By lostguy in forum .NET
    Replies: 8
    Last Post: 04-03-2002, 07:41 PM
  4. queries with Crystal Reports
    By ashok in forum .NET
    Replies: 1
    Last Post: 09-06-2001, 11:26 AM
  5. Script for scrolling
    By Mark in forum Web
    Replies: 3
    Last Post: 08-30-2001, 11:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center