[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Unbound Image

Posted on 2007-10-11
9
Medium Priority
?
1,384 Views
Last Modified: 2008-01-09
Using Visual Studio version of Crystal Reports, is there any way I can use an unbound image in my report?  
-What type of object do I add in the report designer?
-What code do I use to assign the bitmap bytes to the object in VB.NET or C#?

The examples I see use image fields in a datatable.  I don't need that because there's only one image I'm importing for each report.
0
Comment
Question by:PaulHews
  • 4
  • 3
8 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 20060482
Here is a VB example of loading a picture at runtime.
http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9_vb_rdc_loadpic.exe.asp

mlmcc
0
 
LVL 38

Author Comment

by:PaulHews
ID: 20060566
That's VB6 and CR9.  I'm not able to get that sample to run here as the form doesn't load the crystal viewer.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 20060789
I understand.  You can open the frm files in Notepad and look at the code and convert to VB.Net

mlmcc
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 101

Expert Comment

by:mlmcc
ID: 20060809
This code is for the format event of the section where the picture goes

Private Sub Section3_Format(ByVal pFormattingInfo As Object)

'To load an image from a file, use the VB function, LoadPicture.
'The Picture object in this section has a formattedpicture property that
'accepts the results of the LoadPicture function

'First we get the path of the picture, it is in the data\pictures
'subdirectory of the application

   
   picFile = App.Path & "\data\Pictures\"

'Add the full file name. The file name will be the Value of
'the name field (field1) with a .bmp extension

   picFile = picFile & Field1.Value & ".bmp"

'Set the formattedpicture property of the picture1 object
'to the LoadPicture function

   Set Picture1.FormattedPicture = LoadPicture(picFile)
End Sub


mlmcc
0
 
LVL 38

Author Comment

by:PaulHews
ID: 20061278
I have a ReportDocument object.  I load it like this:

MyReport.Load(ReportPath)

It exposes InitReport and RefreshReport events and I don't see section_format events anywhere.  I tried

Private WithEvents ChartSection As Section

because I can access the section through the ReportDocument.ReportDefinition.Sections collection.  Unfortunately that object doesn't seem to expose any events.

There's no report (*.rpt) in that project that I can load, edit or view, so what is the Picture1 object?  I've tried PictureObject type:

Dim crysPic As PictureObject = DirectCast(MyReport.ReportDefinition.ReportObjects(PicName), PictureObject)

But I'm not seeing FormattedPicture as a property to that type of field...
0
 
LVL 38

Author Comment

by:PaulHews
ID: 20061581
This works:
http://forums.microsoft.com/msdn/showpost.aspx?postid=281779&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=1

I hope I'll be able to adjust where the OLE Link points at runtime however, since I can't hard code a path into this report...
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 0 total points
ID: 20067116
I think it's possible to relocate an OLE link using the Crystal API which is not available in the VS.NET version.  So I've given up on the unbound image idea... It just doesn't seem to work with the limited version that ships with Visual Studio.  (I could be wrong, but it's hard to tell because the documentation is extremely limited for this version.)

I've added an extra table to the dataset with one column of type System.Byte() for the image.  Bind the report to the new dataset and drag the new field onto the report (BLOB field type.)

Dim MemStream As New System.IO.MemoryStream
Pic.Picture.Save(MemStream, Imaging.ImageFormat.Bmp)
ds.Tables("ImageTable").Rows.Add(MemStream.GetBuffer)
MemStream.Dispose()

This works like a charm without the kludge of saving to temp files, etc.
0
 
LVL 1

Expert Comment

by:modus_operandi
ID: 20112747
Closed, 500 points refunded.
modus_operandi
Community Support Moderator
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 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