Solved

Crystal Reports: Programmatically change graphic in PageHeaderSection

Posted on 2012-04-03
3
577 Views
Last Modified: 2012-05-10
Software: Visual Studio 2005 Crystal Reports.

I have an application written in VB.Net, Sql Server and use Crystal Reports for printing several custom designed documents.

I would like to sell the application but may have a problem with the printing because each document has unique company names and logos in the ReportHeaderSection and the PageHeaderSection.

It would take a long time to change the information for each user manually - is there a way to do this programmically with code?

Thanks!
0
Comment
Question by:dave_sky
3 Comments
 
LVL 5

Accepted Solution

by:
hafeezmca earned 500 total points
ID: 37803370
This solution applies if you are using a plain old C# Object to populate your Crystal Reports (see http://www.aspfree.com/c/a/C-Sharp/Crystal-Reports-for-Visual-Studio-2005-in-CSharp/  for info on this approach).

In your C# class, insert the following code:

private static byte[] m_Bitmap = null;

public byte[] Bitmap
{
   get
   {
      FileStream fs = new FileStream(bitmapPath, FileMode.Open);
      BinaryReader br = new BinaryReader(fs);
      int length = (int)br.BaseStream.Length;
      m_Bitmap = new byte[length];
      m_Bitmap = br.ReadBytes(length);
      br.Close();
      fs.Close();
      return m_Bitmap;
   }
}

Now, update your C# Object Mapping in CR using the "Verify Database" option. You should then see the Bitmap property as a CR field. Just drag it onto the form. It will be of type IBlobFieldObject. When you run, you should see your image.

Reference:  http://stackoverflow.com/questions/128239/dynamically-change-an-image-in-a-crystal-report-at-runtime
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now