Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. load a .gif image at runtime in crystal report

load a .gif image at runtime in crystal report

Scheduled Pinned Locked Moved C#
xmlcsharpdatabasehelp
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dhol
    wrote on last edited by
    #1

    Hi 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 tbl.Rows.Add(row); // 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(*.*) | *.*"; openFileDialog1.ShowDialog(this); //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 data.Tables.Add("Images"); // 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[]")); AddImageRow(data.Tables[0],mypic,mypic); // create a report showimage cr = new showimage(); cr.SetDataSource(data); // pass a reportdocument to the viewer crystalReportViewer1.ReportSource = cr; }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups