Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Can you point me in the right direction (or show me the code) to load an photo into a xrPictureBox at runtime, I have a report template which end users can change (add / remove fields etc) however the photos are not stored in a database (just in a folder), so I need some code that the end user can add to the xrPicurebox script event to populate the image at runtime, if they place an image on the report.

                                    Thanks

                                    Tim

                                0

                                Hi Tim,

                                I believe you can easily embed a picture into the report via the XRPictureBox -> Image smart tag option.
                                However, it's also possible to update an image at runtime. For instance, this can be done by handling the XRPictureBox.BeforePrint event.
                                Refer to this sample code snippet:

                                	
                                [VB.NET]
                                Imports DevExpress.XtraReports.UI Private Sub OnBeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Dim pic As XRPictureBox = CType(sender, XRPictureBox) pic.Image = Image.FromFile("C:\picture.jpeg") End Sub

                                Thanks,
                                Alex.

                                Q146189.png
                                0

                                Alex,

                                Can you show me the exact code in C#. I've tried the following but with no success

                                ((XRPictureBox)sender).Image = Image.FromFile("C:\\Test.jpg");

                                Thanks
                                Tim

                                0

                                Hi Tim,

                                Please make sure you have referenced the DevExpress.XtraReports.UI namespace via the 'using' directive:

                                	
                                [C#]
                                using DevExpress.XtraReports.UI; private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { ((XRPictureBox)sender).Image = Image.FromFile("C:\\Test.jpg"); }

                                BTW: I've noticed that the VB.NET language is specified in your client's profile, although you have requested a C# code snippet.
                                It's always better to keep your profile information up to date, so that we can provide you with code samples in the appropriate language.

                                Thanks,
                                Alex.

                                0

                                Alex,

                                Thanks, I've managed to resolve the issue by deleting the exisitng picturebox and adding in a new one. I suspect that the issue was due to the orignal picture box having some other code in its OnBeforePrint event (not in the script, but in the actual program).

                                Once again thanks for you help.

                                Tim

                                0

                                Hi Tim,

                                Glad to be of help. Please feel free to contact us in case of any difficulty - we'll be happy to help you.

                                Thanks,
                                Alex.

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners