DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: load a .gif image at runtime in crystal report

  1. #1
    Join Date
    Sep 2005

    load a .gif image at runtime in crystal report


    I have done a program in C# such that , added a crystal report viewer, then added a button named as browse… and designed a report by getting source from the xml schema file(.xsd file) with two fields namely name,image..... name is of string datatype and image is of
    datatype base64Binary.. so now when I run the program.. using browse button I can be able to load a .jpg image at runtime.. so that image will be displayed in the report…. This is wht my program does…

    Now what I have to do is that ,I should be able to load a .gif image at runtime and display in crystal report.At present when I select a .gif image..its not shown in crystal report…so please help me to do this.. I will enclose my coding part along with this..please have a look at it and help me to do this program….

    and the coding is as follows:

    // Prcocedure: AddImageRow
    // reads an image file and adds this image to a dataset table
    void AddImageRow(DataTable tbl, string name, string filename)
    FileStream fs = new FileStream(filename, FileMode.Open); // create a file stream
    BinaryReader br = new BinaryReader(fs); // create binary reader
    DataRow row;

    // create a new datarow
    row = tbl.NewRow();

    // set country field and image field
    row[0] = name;
    row[1] = br.ReadBytes((int)br.BaseStream.Length);

    // add this row to the table

    // clean up
    br = null;
    fs = null;

    //Browse button
    private void button1_Click(object sender, System.EventArgs e)
    OpenFileDialog openFileDialog1 = new OpenFileDialog();
    // openFileDialog1.Filter = "Image Files(*.jpg) | *.jpg ";
    openFileDialog1.Filter = "Image Files(*.jpg) |*.jpg | All Files(*.*) | *.*";
    //the variable myPic contains the string of the full File Name,it includes the full path.
    string mypic = openFileDialog1.FileName;

    DataSet data = new DataSet();

    // add a table 'Images' to the dataset

    // add two fields
    data.Tables[0].Columns.Add("Country", System.Type.GetType("System.String"));
    data.Tables[0].Columns.Add("img", System.Type.GetType("System.Byte[]"));


    // create a report
    showimage cr = new showimage();
    // pass a reportdocument to the viewer
    crystalReportViewer1.ReportSource = cr;


  2. #2
    Join Date
    Nov 2003
    Portland, OR
    If you don't get an answer here, you might try Crystal's tech support site:
    Phil Weber

    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
    Mar 2009
    simply you can use transparent PNG files instead of gif! ;D

  4. #4
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    Quote Originally Posted by smaildeveloper View Post
    simply you can use transparent PNG files instead of gif! ;D
    What would that do for him?

Similar Threads

  1. Replies: 1
    Last Post: 02-20-2008, 05:30 AM
  2. Replies: 1
    Last Post: 11-08-2005, 09:42 AM
  3. Replies: 1
    Last Post: 10-07-2005, 01:54 AM
  4. Working with Crystal Report Ver 10
    By AM003295 in forum VB Classic
    Replies: 4
    Last Post: 08-12-2005, 09:13 PM
  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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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