CppMax Homepage
Forum Home Forum Home > ReportMax > ReportMax
  New Posts New Posts RSS Feed - Setting Imagefield image property by code
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Setting Imagefield image property by code

 Post Reply Post Reply Page  12>
Author
Message
Henner View Drop Down
Newbie
Newbie


Joined: 05 Oct 2015
Location: Herford/Germany
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Henner Quote  Post ReplyReply Direct Link To This Post Topic: Setting Imagefield image property by code
    Posted: 05 Oct 2015 at 5:56pm
Hi.
In my query result I have a datafield which contains a full path to an image.
How can I display this image (from file) on a report?

What I did by now:
Putting an image field to the report.
Setting DataField to my datafield in the query result (i.e. PicPath) which is a string value.

I cannot see the image on the report.
Is the DataField used for BinaryData?

The Image and Image URL properties seem not to be the right properties.

I have so much questions. Sorry for that.
Is there an user manual for control available?

Thanks again
best regards
Henner

Back to Top
emadns View Drop Down
Admin Group
Admin Group


Joined: 06 Feb 2012
Status: Offline
Points: 130
Post Options Post Options   Thanks (0) Thanks(0)   Quote emadns Quote  Post ReplyReply Direct Link To This Post Posted: 05 Oct 2015 at 6:12pm
No worries. We understand that there is a shortage of documentation and we will improve that. Currently we provide a tutorial document in the Programs menu under CppMax -> ReportMax.

The Image DataField expects a field of BLOB type (binary) but we will add a feature that will allow file paths in the next release.

If you add an event (Report_Start), you can have the following code:

using CppMax.ReportMax;

...

Report_Start(... FilePage, ...)
{
   ReportMaxImage image = (ReportMaxImage)FilePage.FindControl("Image1");

   image.Image = new Bitmap(<image file path>);

}
Back to Top
emadns View Drop Down
Admin Group
Admin Group


Joined: 06 Feb 2012
Status: Offline
Points: 130
Post Options Post Options   Thanks (0) Thanks(0)   Quote emadns Quote  Post ReplyReply Direct Link To This Post Posted: 05 Oct 2015 at 6:15pm
Or at form load you can have the following code:

...
Me.ReportMaxViewr1.LoadReport();
ReportMaxImage image = (ReportMaxImage)Me.ReportMaxViewr1.m_FilePage.FindControl("Image1");
image.Image = new Bitmap("<from path>");
Me.ReportMaxViewer1.ExecuteReport();
Back to Top
Henner View Drop Down
Newbie
Newbie


Joined: 05 Oct 2015
Location: Herford/Germany
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Henner Quote  Post ReplyReply Direct Link To This Post Posted: 05 Oct 2015 at 6:53pm
cool!
Very fast support. I give it a try tomorrow.
Too late now in Germany.Smile
Thanks and good night
best regards
Henner
Back to Top
Henner View Drop Down
Newbie
Newbie


Joined: 05 Oct 2015
Location: Herford/Germany
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Henner Quote  Post ReplyReply Direct Link To This Post Posted: 06 Oct 2015 at 7:27am
Sorry, I cannot get that code running.
Looks like C# with the semicolons and the declaration of image.
I get blue lines under the code.

I have a public function "getThumbnailFromFile" that returns a thumbnail
as a System.Drawing.Image object.
I think all I need is to connect the given thumbnail to the "Image1" control
on my report.
Something like this pseudo code:
Me.ReportMaxViewer1.Image1.Image=getThumbnailFromFile(xSize,ySize,PathToPicture)

Thanks again
Henner

Back to Top
emadns View Drop Down
Admin Group
Admin Group


Joined: 06 Feb 2012
Status: Offline
Points: 130
Post Options Post Options   Thanks (0) Thanks(0)   Quote emadns Quote  Post ReplyReply Direct Link To This Post Posted: 06 Oct 2015 at 10:38am
Oh, so you are using vb.net. Here is an example

' load the report if not loaded
Me.ReportMaxViewer1.LoadReport()
' get the ReportMaxImage control named Image1
ReportMaxImage image = (ReportMaxImage)Me.ReportMaxViewer1.FindControl("Image1")
' assign the image to image.Image
image.Image = new Bitmap(GetThumbnailFromFile(xSize, ySize, PathToPicture))
' execute the report if not executed
Me.ReportMaxViewer1.ExecuteReport()


Back to Top
Henner View Drop Down
Newbie
Newbie


Joined: 05 Oct 2015
Location: Herford/Germany
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Henner Quote  Post ReplyReply Direct Link To This Post Posted: 06 Oct 2015 at 12:02pm
Thanks Emad,
yes I am using vb.net (even if I will be the last on earth who uses it Wink)
C# is not my thing. But anyway, if I use your code-snippet same error occurs.
It still looks like C#:
ReportMaxImage image = (ReportMaxImage)Me.ReportMaxViewer1.FindControl("Image1")
So, still blue lines only under the part "ReportMaxImage image= (ReportMaxImage)Me"
Tooltipp when MouseOver "ReportMaxImage" says:
"ReportMaxImage" ist ein Typ und kann nicht als Ausdruck verwendet werden.
Google Translation:
"ReportMaxImage" is a type and can not be used as an expression.
Same tooltipp when hover over "image" and over "(ReportMaxImage)"
Tooltipp on "Me" says:
Komma, ")" oder g├╝ltige Ausdrucksfortsetzung erwartet
Translation:
Comma ")" or a valid expression continuation expected

If I set this comma between ")" and "Me", the blue underlining extends until the end of
"FindControl" and tooltipp says "FindControl is not a member of ReportMaxViewer"

I think there is the "m_FilePage" part missing between "Viewer1" and "FindControl"

Thanks for reading this long post.
Can you please have again an eye on that
Thanks in advance
Henner
Back to Top
Henner View Drop Down
Newbie
Newbie


Joined: 05 Oct 2015
Location: Herford/Germany
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Henner Quote  Post ReplyReply Direct Link To This Post Posted: 06 Oct 2015 at 12:53pm
OK Emad, I think I solved the problem.
Code follows in a minute
Back to Top
emadns View Drop Down
Admin Group
Admin Group


Joined: 06 Feb 2012
Status: Offline
Points: 130
Post Options Post Options   Thanks (0) Thanks(0)   Quote emadns Quote  Post ReplyReply Direct Link To This Post Posted: 06 Oct 2015 at 1:13pm
Great. I was actually adding VB.net to my Visual Studio in order to fix the code for you. But glad that you fixed it.
Back to Top
Henner View Drop Down
Newbie
Newbie


Joined: 05 Oct 2015
Location: Herford/Germany
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Henner Quote  Post ReplyReply Direct Link To This Post Posted: 06 Oct 2015 at 1:23pm
Tested with VisualStudio 2013 Community Edition
Here is the vb.net code that works fine for me:
'--snip
            'define the ReportFile wtih the content of a public string variable
            Me.ReportMaxViewer1.ReportFile = strReportFile
            'Load the report
            Me.ReportMaxViewer1.LoadReport()
            'define the Image Path
            'full path for testing only, normally the Path is in a public string variable like strReportImagePath
            strReportImagePath = "C:\Folder\SubFolder\Imagename.jpeg"
            'Check if the Report Field is an Image Field
            If Me.ReportMaxViewer1.m_FilePage.FindControl("Image1").GetControlType = rmReportFieldType.rmFieldImage Then
                'Create Image container
                Dim myImage As ReportMaxImage
                'get height and width of te Image control
                'use it  to define the height and width for the thumbnail creating function to fit exactly into the image control
                'cast the value to integer just to be sure to have an integer value for the thumbnail creation
                Dim intHeight As Integer = CInt(Me.ReportMaxViewer1.m_FilePage.FindControl("Image1").m_nHeight.ToString)
                Dim intWidth As Integer = CInt(Me.ReportMaxViewer1.m_FilePage.FindControl("Image1").m_nWidth.ToString)
                ' cast the ReportMaxImage control named Image1 to a ReportMaxImage
                myImage = CType(Me.ReportMaxViewer1.m_FilePage.FindControl("Image1"), ReportMaxImage)
                'Get the thumbnail and assign to the image container
                myImage.Image = CType(getThumbnailFromFile(strReportImagePath, intWidth, intHeight), Bitmap)

            End If
            ' execute the report if not executed
            Me.ReportMaxViewer1.ExecuteReport()
'--snap



Thanks again Emad for your fast support
Next question will be posted.
My application has a multilingual UI. So I have to change the labels in the fly.
I will post that soon.
best regards
Henner
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.06
Copyright ©2001-2016 Web Wiz Ltd.