473,471 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

load an image based on a provided filepath in the report at runtim

Hi

I have to program in C# such that I have to add a button to the form , and
create a crystal report, by getting source
from the xml schema file(.xsd file) with two fields namely name,image.....
name is string datatype and image is of
datatype base64Binary. Now i have to add a crystal report viewer to the form
and whenthe program is run, we
should be able to load any image ,ie, by clicking the button add any image
from the disk and that image should be displayed
in the report in image column......
so wht i have to do is
-create a dataset that supports images
-create a report that support this dataset
-load data in the dataset
-use the dataset as datasource for the report and show the report in the
viewer

Then i found a code in Vb...
please change for me in c# and explain how to do...

i will paste the coding part
Code:
Private Sub btnLoadImage_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnLoadImage.Click

Dim ofdImage As New OpenFileDialog

If ofdImage.ShowDialog = DialogResult.OK Then

Try

'Create a new instance of the dataset
Dim dsImgRpt As New dsImageReport

'Create a new instance of the report
Dim m_imagereport As New rptImage

'Create a new row in the dataset
Dim dr As dsImageReport.ImageRow = _
dsImgRpt.Image.NewImageRow

'Set the various elements of the row
dr.Name = ofdImage.FileName
'fill this field with a byte array
dr.Photo = GetImageData(ofdImage.FileName)

'Add the new row to the dataset
dsImgRpt.Image.Rows.Add(dr)

'Use the dataset as datasource for the report
m_imagereport.SetDataSource(dsImgRpt)

'Show the report in the reportviewer
Me.crystalReportViewer1.ReportSource = m_imagereport

Catch ex As Exception

MessageBox.Show("Something went wrong: " & ex.Message)

End Try

End If

End Sub

Private Function GetImageData(ByVal fileName As String) As Byte()

'Method to load an image from disk and return it as a bytestream
Dim fs As System.IO.FileStream = _
New System.IO.FileStream(fileName, _
System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim br As System.IO.BinaryReader = New System.IO.BinaryReader(fs)
Return (br.ReadBytes(Convert.ToInt32(br.BaseStream.Length )))

End Function
please help me to do this..

batista
Nov 17 '05 #1
0 1673

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: haddock | last post by:
hi all Is it possible to access the size (with and height) of a .tga image in python? From the documentation I would say no, but I'm pretty new to python... if the answer really is no, has...
4
by: Shumit Rehman | last post by:
Hi I have a table which has path names to photos I would like to view. I would like to open some/any kind of image viewer(Paint) to see the picture when I click the pathname. The pictures are...
3
by: Gary B | last post by:
I'm converting a windows application to a web application. (by the way, this is way easier than it used to be - many of the modules went over untouched!) The windows app used a pictuebox and...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
6
by: comp.lang.php | last post by:
/** * Generate the random security image * * @access public * @param $willUseFilePath (default false) boolean to determine if you will be using a file path * @param mixed $filePath (optional)...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
1
by: ckarbass | last post by:
I'd like for the file download dialog to be launched upon page load. The workflow or behavior is exactly the same as sourceforge's. I've searched on google to no avail. Any help would be...
4
hemantbasva
by: hemantbasva | last post by:
We have designed an aspx page having five ajax tab in it. the data of first four are designed on page whereas for the fifth tab it renders a user control named MYDOMAIN. in the tab container's even...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.