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. image at runtime

image at runtime

Scheduled Pinned Locked Moved C#
csharpxmltutorial
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 am working in c# with crystal report XI. I read an example about dynamic image location .. 1) In that we have a xml xchema file with two fields n amed country--datatype is string, img--datatype is base64Binary. using this as the datasource,i have designed the crytal report. And a parameter is set asking for the name. 2) I have designed teh form by adding a crystal report viewer and now the coding part is as follows // Prcocedure: AddImageRow // reads an image file and adds this image to a dataset table // // [in] tbl DataTable // country name of a country // filename name of an image file // 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; } // Function: CreateData // Creates a dataset that has 1 table with two fields: Country (string), and img (blob/byte[]) // Adds four records to this table // DataSet CreateData() { 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[]")); // add rows AddImageRow(data.Tables[0], "argentina", Directory.GetCurrentDirectory() + "\\argentina.jpg"); AddImageRow(data.Tables[0], "canada", Directory.GetCurrentDirectory() + "\\canada.jpg"); return (data); } // Procedure: CreateReport // Creates a report and passes the dataset // void CreateReport() { // create a report CrystalReport1 cr = new CrystalReport1(); cr.SetDataSource(CreateData()); // pass a reportdocument to the viewer crystalReportViewer1.ReportSource = cr; } public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // CreateReport(); } This is the coding part..ie,when the program is run the image which is existing in the directory (say argentina.jpg and canada.jpg). it will ask for country name...so if we type canada..then canada.jpg wil be displyed in

    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