Blogs

DevExpress Reporting Blog

  • CodeMash / Michigan Tour Recap

         

    Mehul and I had a great time at this year's Codemash conference held in Sandusky, Ohio Jan.11-13! We want to thank  the organizers for another amazing conference, as usual they were fantastic hosts.  We had a blast at our booth giving away lots of swag like t-shirts and bags and also gave away  copies of Visual Studio Ultimate to two very lucky attendees.  It was awesome. 

    And, if you know me, you know I love to talk and spread the word about DevExpress so the Codemash folks kindly  let me present a mini session about making stylish Metro inspired applications today. Here is a good screenshot:

    DevExpress CRM Metro Inspired Demo

    I love data analysis and therefore am enjoying our push to liven your data very much. I also had the privilege of reminding folks about our free WPF map offer! I showed off how easy it is to add that elusive extra dimension to your data.

    In addition to CodeMash, Dave Giard invited me to talk at several Michigan user groups.  So I left Ohio behind and forged  my way around the southern part of the state from the Greater Lansing .NET UG to Kalamazoo's Microsoft Developers of Southwest Michigan UG, Southfield's  Great Lakes Area .NET UG and finally the Ann Arbor .NET Developer's Group. I had a chance to meet a lot of cool developers and customers doing great things. Thanks for having me everyone, it was a pleasure!

    I had the privilege of talking about a wide range of topics in C#, AI, and Machine Learning to name a few. Michigan is a wonderful state and I hope I have the privilege of being welcomed again.

    Looking forward to next year's CodeMash which is already scheduled for Jan.9-11, 2013.

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • BASTA Spring and DevExpress Day in Germany!

         

    bastaToday I will be leaving for Germany to attend BASTA spring as well as have a special DX day. Let me tell you about each event:

    BASTA

    I am excited to have the opportunity to give two talks at BASTA. I have been working very hard to re-vamp my machine learning talks in order to reach a wider audience. I have also been busy at work making the demos a whole lot better. Given our recent push in assisting developers build stunning applications, I took the challenge to heart and have made some improvements to the visualizations for my presentation. Take a look:

    Unsupervised-KMeans

    This is a demonstration of the unsupervised learning algorithm called KMeans. This (and many other stunning screens) will be used in conjunction with my 2 BASTA presentations on Machine Learning. One has to do with predicting the future while the other will assist attendees to better understand the past. Both sessions will be on Tuesday February 28th at 4:15PM CET and 5:45PM CET respectively. I will also be on hand during three “Ask the Expert’s” slots on Tuesday (1:00-2:30PM), Wednesday (1:00-2:30PM), and Thursday (12:30-2:00PM). If you are in the area I would love to chat!

    DevExpress Day

    Before BASTA even begins, Oliver Sturm has set up a DX Day Saturday, February 25th 2012 at the Häckers Kurhotel in Bad Ems, Germany. He has graciously invited me to speak on the new Metro inspired features we have created in conjunction with our DXv2 release as well as a good overview of our reporting toolset. You can see more details on his site. It would be great to chat all things DX. The event is free to all who are interested!

    I Would Love to Meet

    If you happen to be in the area and would like to meet (during or after conference hours) let me know! As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • Coming to CodeMash–Staying in Michigan

         

    logo-codemashAnother exciting CodeMash conference is upon us! Mehul Harry and I will be in attendance to answer any questions and spread the good word about DevExpress. We will not come empty handed! We are bringing two copies of Visual Studio Ultimate (Retail > $10,000) with us to give away. You might also coerce us to give away a couple of CodeRush licenses etc. I will also be presenting a mini session about making stylish Metro inspired applications today.

    In addition to CodeMash, Dave Giard was kind enough to invite me to present at several User Groups across Michigan. Here is more information:

    1. Monday the 16th at 6:00 PM - Greater Lansing .NET User Group
      Location
      Techsmith
      2365 Woodlake Drive
      Okemos, MI 48864
    2. Tuesday the 17th at 6:00PM - Microsoft Developers of Southwest Michigan
      Location
      4601 Campus Drive
      Kalamazoo, MI 49008
    3. Wednesday the 18th at 6:00PM - Great Lakes Area .NET User Group / Ann Arbor .NET Developers Group
      Location
      The Epitec Group
      24800 Denso Drive, Suite 150
      Southfield, MI 48033

    I will be speaking a bit about the functional underpinnings of C# as well as some cool Machine Learning topics. As some of you know I love to go off the cuff so let me know if you would like me to talk about anything else.

    I would love to meet you! If you or your company would like to arrange a visit feel free to email me so we can set something up!

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • Building Business Applications with Visual Studio LightSwitch 2011– A Webinar with Alessandro Del Sole (Oct. 4th 10:00AM PST)

         

    I am tremendously excited to welcome Alessandro Del Sole as one of our newest webinar presenters! He is a Microsoft MVP in Visual Basic Development, Author, and all around LightSwitch genius! He will be guiding us through the process of developing real applications using Microsoft’s new addition to the Visual Studio family: LightSwitch.

    His description says it all:

    Visual Studio LightSwitch is the new development tool from Microsoft for rapidly building business applications for the Desktop, the Web, and the Cloud. LightSwitch is for developers of all skill levels, offering lots of coding-optional features, providing a variety of pre-built templates and tools so that the only code you write is for optimizing your business logic. This avoids the need of writing all the code for data access and the user interface, saving you an incredible amount of time. LightSwitch makes it simple to interact with multiple, existing data sources and deploying applications to clients. In this session you will get started with Visual Studio LightSwitch 2011 and you will see how easy and quick it can be to build high-quality, professional business applications, including an overview of the Microsoft technologies running under the hood.

    This webinar is a live training session starting at 10:00AM PST on Tuesday October 4th. I personally was surprised by the amount of things possible with LightSwitch, its general design strategies, as well as how fast I could make real applications. I will also be on hand during the webinar to answer general questions as well as any LightSwitch related reporting questions.

    Register today:

    register

    I look forward to seeing you tomorrow!

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • New LightSwitch Reporting Tutorial in VB

         

    I am happy to announce that we have released a new reporting tutorial for LightSwitch. I personally am not a proficient VB.NET developer but noticed that the majority of folks using our reporting product in LightSwitch were VB fans. I decided to put together a tutorial that covered the essence of reporting in VB. This tutorial includes:

    1. Setting up the reporting extension
    2. Setting up the LightSwitch Report Service
    3. Binding a report to a LightSwitch Entity
    4. Binding a report to a LightSwitch Query
    5. Creating a tight integration between other LightSwitch screens and Reporting.

    Have a look!

    LightSwitch Reporting Tutorial

    As a bit of eye candy I also thought it would be important to create a video showing some of the unknown capabilities that reporting provides in the context of LightSwitch. This video shows off the stuff we all know and love and includes demonstrations of chart and pivot grid integrations. Essentially our Reporting Suite adapted to LightSwitch is your one-stop-shop for all things data.

    LightSwitch Reporting Features

    Let me know what you think!

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • What is the WinRT (Windows Runtime) and what does it have to do with .NET?

         

    There has been a lot of confusion engendered by this infamous architecture drawing (slides courtesy of Microsoft):

    Windows 8 Architecture

    If you zoom in some you should see something like this:

    WinRT Architecture Missing Bits

    For some reason this architecture diagram left out the all-important notion called the Projection. The main idea is that each of the technologies used to plug into the WinRT do not directly call the WinRT but work through a binding called a projection (yes even the C/C++ side). So what is this Chakra business then on the JavaScript side? This is simply the code name for the JavaScript engine that maps to the projection. For C#/VB it goes through a profiled version of the CLR. If you are unsure about what a .NET profile is, here is a reminder picture that jogged my memory:

    .NET Profiles

    When you look at project properties you have different profiles that can be used as targets to your program. In Silverlight you have a similar thing:

    Silverlight Profiles

    The best analogy for Metro (at least from the XAML/C# and VB side) is actually Silverlight. A subset of the namespaces we are used to will be available with a strict emphasis on asynchronous unless otherwise stated. For those familiar with WP7 (which is the closest namespace-wise) there have also been some renaming of namespaces (see msdn for more info). The C/C++ side has a thin projection (which theoretically should not be faster than the other projections but I have my doubts here). The better diagram:

    Better Windows 8 Architecture Diagram

    The green bits represent the WinRT and the orange part represents the projection. Every object in the WinRT has the IInspectable and IUnknown interfaces (sound familiar?). The way they are pushed up is a bit different.

    WinRT Projections in Depth

    The key information that’s been added is the Windows Metadata. This portion is what allows the rich intellisense in Visual Studio 11. Now the C++ projection (as far as I understand) does all the binding (ok, projection) stuff at compile time. For the C#/VB apps the story is a bit different. Some of the projection/binding happens at compile time and some happens at runtime. We are being told, however, that this is negligible (hence my doubts).

    Mehul and I chatted a bit about the WinRT on our recap video at the //BUILD/ conference. Notice that when I talk about the WinRT I specifically say that it is not .NET. Hopefully the discussion we had helped clear this up! This does not mean that we cannot write .NET code on top of the WinRT. This is done via the projection mechanism discussed.

    I plan to do similar posts (I’ve been chewing my arm off trying to talk about this stuff!) on the WinRT especially when it comes with the namespaces and classes and what exactly has been exposed to the developers.

    I would love your take on the matter! Also, I have been known to make mistakes. Let me know if you find any glaring ones so I can correct them!

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • Microsoft Build Conference 2011: Ted Neward’s Take on Day 1

         

    It was awesome to get community feedback on what is going on with Windows 8. In this post I do a little recap of what Ted Neward had to say after day 1. Here is a summary:

    • Reactions to Windows 8 (specifically the tablet and store stories)
    • Comments about Microsoft’s Execution and strategy behind releasing hardware and bits
    • Thoughts on the FUD (Fear, Uncertainty, and Doubt) coming into the //BUILD/ Conference
    • Ideas on the tight integration (AKA WinRT) as well as new app contracts
    • Thoughts on what DevExpress can do in this new model
    • Jedi words of wisdom – Patience and execution

    Take a look at the interview:

    Ted Neward BUILD Conference

    The coolest thing about Ted is that he has the pragmatic edge to help us understand what is really going on and how we can move forward.

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • WPF and Silverlight Reporting - Support for Document Watermarks

         
    This blog post announces a useful enhancement applied to our DocumentPreview control in the next version of the XtraReports Suite (v2011 vol 2) - the capability to add text and image watermarks to your report documents created in WPF and Silverlight applications.

    Much in the same way it was possible with our Print Preview for Windows Forms, you can add watermarks by pressing the corresponding button in a Document Preview toolbar.

    The Watermark button in the Document Preview for WPF and Silverlight

    In the invoked dialog, choose to add a text or image watermark (or both) by switching to the corresponding tab.

    Adding text watermark in WPF and Silverlight

    After adjusting the required options, the watermark is applied to specified document pages.

    Adding image watermark in WPF and Silverlight
  • Using Visual Studio for Script Debugging in XtraReports

         

    We are happy to announce yet another little improvement in the next version of the XtraReports Suite(v2011 vol 2) - the ability to debug report scripts in Visual Studio.

    To enable this feature, add the following lines enclosed in the <system.diagnostics> tags to the <configuration> section of the config file of your application (or the web.config file of your ASP.NET application).

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.diagnostics>
        <switches>
          <add name="AllowDebugXtraReportScripts" value="true"/>
        </switches>
      </system.diagnostics>
    </configuration>

    Then run your application and attach Microsoft Visual Studio to this process.

    Attaching to a Process in Visual Studio

    How to attach to a process in Microsoft Visual Studio

    After calling the CreateDocument() method for your report (e.g. when switching to the Preview tab in an End-User Designer), the corresponding script code is available at Visual Studio runtime, and it is possible to set a breakpoint on it.

    Setting a breakpoint at Visual Studio runtime

    After finishing debugging your scripts, you may wish to remove all temporary files that are created to provide this functionality. They are located in the following directory: C:\Users\User_Name\AppData\Local\Temp

    Removing temporary files  

  • Silverlight Project Wizard

         

    As I was getting ready to start documenting the new reporting features coming in our second release in 2011, I came across a cool little project template when starting up a Silverlight project:

    newwiz

    Needless to say I got curious so I clicked on it to see what kinds of things could be done with the new Wizard. I was pleasantly surprised:

    Silverlight Project Wizard

    In my brief Silverlight experience, I have found it a pain to produce the standard types of layouts required of almost all software packages. This problem was definitely ameliorated by our fantastic Docking and LayoutControl. This Wizard is a definite += 1 on how easy it will be to produce new Silverlight Applications because it leverages both the Docking and the LayoutControl to produce the kinds of layouts our users have come to expect in our software. Here is the result after leaving the defaults and clicking Create Project:

    Silverlight Application

    This all took a matter of seconds.

    Happy Coding!

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • Embedding a Document Preview for WPF into the End-User Designer

         
     This blog post outlines the process of adding a Document Preview for WPF to an End-User Report Designer for Windows Forms. The complete application is available in our Code Central at How to embed a Document Preview for WPF into the End-User Report Designer for Windows Forms.

    To solve this task, do the following.

    1. Create a new Windows Forms application and to make it possible to create an End-User Designer, change its target framework to the full profile of the .NET Framework 4

    Setting an application's target framework to the full .NET Framework 4 profile

    Add the following assemblies to the project's reference list.

    Adding DevExpress assemblies to create a custom End-User Report Designer

    2. Next, let's create a custom End-User Designer form, by assembling it from its constituent user interface elements.

    To do this, drop an XRDesignBarManager onto the main form of your application. After adding this control, two other components are auto-added to the form: XRDesignMdiController and XRTabbedMdiManager. To simplify this example, we will remove them, and will instead use an XRDesignPanel to conform to a single-document interface.

    Create a Custom End-User Designer form with DevExpress XtraReports

    After this, make sure to disable the IsMdiContainer property of the main form.

    Providing a single-document interface to the End-User Report Designer

    3. Then, drop an XRDesignDockManager control onto the main form’s surface.

    Creating a custom End-User Report Designer

    4. Now, let's provide a WPF report preview to the Designer.

    To do this, add a new WPF user control (named WpfReportPreviewControl) to your application. 

    Adding a WPF User Control to the application

    5. After you have created WpfReportPreviewControl, write the following code into it, which returns a ReportPreviewModel object.

    using System.Windows.Controls;
    using DevExpress.XtraReports;
    // ...
    
    namespace WindowsFormsApplication1.WPF {
        public partial class WpfReportPreviewControl : UserControl {
            public IReport Report { 
                get { return ((ReportPreviewModel)preview.Model).Report; }
                set { ((ReportPreviewModel)preview.Model).Report = value; }
            }
            public WpfReportPreviewControl() {
                InitializeComponent();
            }
        }
    }

    6. At design time, drop a DocumentPreview control onto the created WpfReportPreviewControl ...

    Drop a Document Preview

    ... and then assign a ReportPreviewModel instance that we have previously created in code to its Model property.

    <dxp:DocumentPreview Name="preview">
        <dxp:DocumentPreview.Model>
            <local:ReportPreviewModel />
        </dxp:DocumentPreview.Model>
    </dxp:DocumentPreview>
    

    7. Add the DevExpress.Xpf.Core and the DevExpress.Xpf.Printing assemblies to the project's reference list.

    8. Then, add a Windows Forms user control to the application.

    Adding a User Control to a Windows Forms application

    9. At design time, drop an ElementHost control onto its surface.

     Using ElementHost

    10. Click its smart tag, and in its actions list, set the SelectHostedContent property to the created WPF user control.

    Setting the SelectHostedContent property of the ElementHost

    11. In its code, define the Report property for the Windows Forms user control.

    public partial class WpfReportPreviewUserControl : UserControl {
        public IReport Report {
            get { return wpfReportPreviewControl1.Report; }
            set { wpfReportPreviewControl1.Report = value; }
        }
        // ...
    }

    12. Now, just add two more classes to the application:

    - BarButtonTabPage.cs that inherits from the XtraTabControl.TabPage and provides the functionality to the WPF Preview page. You can add this page to the Design Panel in its DesignHostLoaded event handler;

    - Helper.cs that will store a report in a stream and assign it to the Report property of the WPF Preview in the button's Click event handler.

    The following image shows the result.

    a Document Preview for WPF in the End-User Report Designer for Windows Forms 

     

    You can view the full code of the application and download it from our Code Central at How to embed a Document Preview for WPF into the End-User Report Designer for Windows Forms.

  • LightSwitch Reporting - Showing Report Preview for Individual Records

         

    This blog post provides a walk-through for the process of integrating XtraReports into your LightSwitch application to show a report preview for individual data records.

    To solve this task, do the following.

    1. Start a new LightSwitch application or open an existing one. Add a data source to the application. 

     Adding a data source to a LightSwitch application

    In this example, we will create a Categories-Products table relation from a sample Northwind database to create a hierarchical report.

    Choosing data objects in LightSwitch

    2. Add a new screen to your application.

    Adding a new screen in LightSwitch

    Choose a List and Detail Screen and set its data source to NorthwindData.Categories.

    Providing screen information in LightSwitch

    3. Double-click Properties in the Solution Explorer and add an XtraReports extension to the application.

    How to add Xtrareports extension to a LightSwitch application

    4. Choose to add another data source in the Solution Explorer, but this time choose WCF RIA Service in the invoked wizard.

    How to add a data source in LightSwitch

    Then, choose XtraReportsService and click Next. On the last wizard page, check to select all available Entities and click Finish.

     Adding a reporting service in LightSwitch

    Note: we do not recommend you changing the default data source name (XtraReportsServiceData), because of the risk that your application will not work.

    5. Create a LightSwitch query, in which categories are selected based on an integer parameter. 

     Adding a query in LightSwitch

    6. To add an XtraReport to the application, switch to the File View in the Solution Explorer, select Server and press CTRL+SHIFT+A.

    In the invoked dialog, choose XtraReport Class v11.1 and click Add

    7. Re-build the solution and bind the report to the created query. 

    How to bind an XtraReport to a LightSwitch Query

    To access the query's parameters, right-click lightSwitchDataSource1 and click Properties. Then, click the ellipsis button for the QueryParameters property.

    Accessing LightSwitch Query properties in XtraReports

    In the invoked dialog, disable the parameter's Visible property.

    Changing a LightSwitch Query parameter's visibility in XtraReports.png

    Then, adjust the report layout as required. To learn how you can create a master-detail report, see How to: Create a Master-Detail Report using Detail Report Bands.

     Adjusting the report layout to create a master-detail report in XtraReports

    8. Switch back to the Logical View in the Solution Explorer and add another screen to the application.

    At this time, select Report Preview Screen and click OK

    Adding a report preview screen to a LightSwitch application

    In the opened screen designer, click "Add Data Item...". In the invoked editor, choose Local Property, set its Type to Integer and Name to CategoryId.

    How to add a local property in LightSwitch

    After the local property is created, press F4 and enable its Is Parameter option in the invoked Properties window.

    Making a local property a parameter in LightSwitch

    9. Now, click Write Code to switch to the screen's code behind, and in the body of the CustomizeReportPreviewModel method, assign the value of the parameter that is passed to the report from the query to the value of the created local property.

    namespace LightSwitchApplication {
        public partial class ReportPreviewScreen {
            public void CustomizeReportPreviewModel(DevExpress.Xpf.Printing.ReportPreviewModel model) {
                model.Parameters["CategoryID"].Value = CategoryId;
            }
            partial void ReportPreviewScreen_Activated() {
                this.ReportTypeName = "XtraReport1";
            }
        }
    }

    Namespace LightSwitchApplication
        Partial Public Class ReportPreviewScreen
            Public Sub CustomizeReportPreviewModel(ByVal model As DevExpress.Xpf.Printing.ReportPreviewModel)
                model.Parameters("CategoryID").Value = CategoryId
            End Sub
            Private Sub ReportPreviewScreen_Activated()
                Me.ReportTypeName = "XtraReport1"
            End Sub
        End Class
    End Namespace

    10. Switch back to the CategoriesListDetail screen designer and add a button (named ShowPrintPreview) to the command bar of the Categories list.

    Handle its Execute method to pass the parameter name to the method that shows the report preview screen.

     How to handle the Execute method of a button in LightSwitch

    In addition, you can check whether or not this value is null in the button's CanExecute method body.

    namespace LightSwitchApplication {
        public partial class CategoriesListDetail {
            partial void ShowPrintPreview_Execute() {
                Application.ShowReportPreviewScreen(Categories.SelectedItem.CategoryID);
            }
            partial void ShowPrintPreview_CanExecute(ref bool result) {
                result = Categories.SelectedItem != null;
            }
        }
    }

    Namespace LightSwitchApplication
        Partial Public Class CategoriesListDetail
            Private Sub ShowPrintPreview_Execute()
                Application.ShowReportPreviewScreen(Categories.SelectedItem.CategoryID)
            End Sub
            Private Sub ShowPrintPreview_CanExecute(ByRef result As Boolean)
                result = Categories.SelectedItem IsNot Nothing
            End Sub
        End Class
    End Namespace
    

    Run the application, choose a category and click Show Print Preview.

     How to use XtraReports in LightSwitch

    As a result, a report showing the category details is displayed in a separate screen.

    LightSwitch reporting with XtraReports 


  • Taming your WinForms Grid–Special Key Behaviors

         

    Yes, I know, I am the reporting guy. I’ll have you know, however, that I was also a DevExpress customer starting all the way back in 2006! I recently looked into our fancy issue tracking application and saw an entry on the 3rd of July 2006. With that in mind I want to come out an categorically state that I am a WinForms fan boi (and have been for quite some time). With that in mind, I recently got an email asking something like this:

    I want the grid to go to the column directly below the current when I hit enter. I also want the text to be edit-ready as well. How do I do this?

    So I dug in. Turns out it isn’t too hard! The first thing is to handle the KeyUp event on the GridView:

    private void gridViewMain_KeyUp(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.Enter)
        {
            var handle = gridViewMain.FocusedRowHandle;
            if (handle > -1)
            {
                var col = gridViewMain.FocusedColumn;
                gridViewMain.FocusedRowHandle = ++handle % gridViewMain.RowCount;
                gridViewMain.FocusedColumn = col;
                gridViewMain.ShowEditor();
            }
        }
    }

    The gist:

    1. Get the focused row along with the currently focused column and save them
    2. Add one to the row handle and make this the the currently focused row (the % stuff makes it wrap to the top once it reaches the bottom)
    3. Set the focused column to the one we stored
    4. Show the editor.

    Done! Here is what it looks like:

    grid

    The skip you see in the animation is due to the looping and not the code Winking smile

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

  • ASP.NET Reporting - An Important Change in the Client-Server Interaction of Report Viewer

         

    This blog post details some changes made in the v2011 vol 1 version of our reporting suite. Specifically I will look at how the ReportViewer in ASP.NET interacts with the server and include some design tips when using our reporting suite in your web applications.

    Starting int the newest reporting version, report documents are no longer created on postbacks, but instead created on a callback This allows each page to be generated on demand.

    For this reason reports should be assigned to a ReportViewer in the Page_Load event handler. After this, a report document is created every time the Web page is re-loaded.

    protected void Page_Load(object sender, EventArgs e) {
        ReportViewer1.Report = new XtraReport1();
    } 

    The only exception to this rule is when you use a ReportDocumentMap with ReportViewer, in which case a report document is created on a postback (to return its bookmark hierarchy to the client).

    In addition, please note that in order to avoid issues regarding the client-server interaction of ReportViewer, we recommend you assign any properties to it either in markup, or in code, but not using both these approaches simultaneously.

    Another feature I would like to highlight is of special importance if your Web application is intended to work with large amounts of data.

    In this case, you can create your report’s data source exclusively when a report document is being generated in the special XtraReport.DataSourceDemanded event handler. For example:

    private void report_DataSourceDemanded(object sender, System.EventArgs e) {
        var dataSet1 = new DataSet1();
        var newRow = dataSet1.DataTable1.NewRow();
        dataSet1.DataTable1.Rows.Add(new object[] { "Field1", "Field2" });
        XtraReport report = (XtraReport) sender;
        report.DataSource = dataSet1;
    }
    As always, if you have any questions and/or comments, please do let us know!
  • Creating and Displaying Reports using XPO

         

    Hello! I wanted to start a series describing our fabulous reporting suite by looking at it from three different angles:

    1. Data – where does the report information reside?
    2. Layout – how do we want to present the data within the report pages?
    3. Presentation – what client side technology will we be using for visualizing the reports?

    The distinction between #2 and #3 is subtle yet extremely important. Our reporting suite is agnostic when it comes to #1 and #2 but very specific when it comes to #3. Laying out the report elements on the report itself should be completed (or at least prototyped) before the report is shown in any of our supported environments (WinForms, ASP.NET MVC, ASP.NET WebForms, Silverlight, WPF, and LightSwitch).

    This particular installment will deal primarily with Data and Presentation. We will be looking at using an XPOCollection as the source of the data and then showing how to visualize the report in WinForms and ASP.NET.

    Data

    The first thing to do is create a class library project to house the XPO objects themselves.

    XPO Class Project

    This project has two classes that inherit from XPObject that have a many-to-many association between them. For more details on XPO we have a great Getting Started tutorial if you would like more information.

    XPO Person Object

    The class view above shows the type of data that I added to the Person XPO class. In addition the Category class has a Name and a Description. There is also a many-to-many between Persons and Categories.

    XPO Many-to-many Association

    Layout

    The next thing I did was to add a new class library project to house the actual reports. Once you add a report and add a reference to our XPO library we need to instruct the report to use XPO as its data source. The easiest way to do this is to add an XPCollection to the report’s design surface:

    Report XPCollection

    Once this is done you will have all of the available fields in order to begin laying out the report. We will not spend too much time here. The key is to get some fields on the design surface in order to make sure the whole process is indeed working.

    Presentation – WinForms

    Now its time to add a third project – the WinForms viewer project. Usually I add a button to the existing form and on its click event instantiate and show the report. I thought I would try to add a little more value by showing how to create a custom report viewer form. On the main form drag a PrintBarManager onto the form’s surface:

    Windows Print Bar Manager

    Once this is added you should see all of the elements available in our standard report viewer dialog. Lastly we need to hook up this new report viewer to our report:

    loadreport

    The key element here is to set the print control’s printing system to the reports printing system. This will ensure that both items are talking about the same things when generating the report. The result:

    Windows Report Viewer

    If XPO is left on its own here it will (by default) create an access database to house anything you might end up saving. Now on to ASP.NET!

    Presentation – ASP.NET

    In ASP.NET things are a bit different. In the WinForms project XPO did a lot of the heavy lifting that it simply cannot do in ASP.NET. In this case all we have to do is tell ASP.NET where the database resides. Once we create a new ASP.NET project and add references to the data and reports assembly we add the Access database to the App_Data folder and specify the following in the Application_Startup (in the Global.asax; see docs for more details):

    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup
        string conn = AccessConnectionProvider.GetConnectionString(
            Server.MapPath("~\\App_Data\\data.mdb"));
        XPDictionary dict = new ReflectionDictionary();
    
        // Initialize the XPO dictionary. 
        dict.GetDataStoreSchema(typeof(Person).Assembly);
        IDataStore store = XpoDefault.GetConnectionProvider(conn,
            AutoCreateOption.DatabaseAndSchema);
        XpoDefault.DataLayer = new ThreadSafeDataLayer(dict, store);
    }

    On the Default.aspx page I switch to Design mode and drop a ReportToolbar and a ReportViewer on to the design surface. If we added the references properly we should be able to select the report right on the ReportViewer’s design surface:

    ReportViewer Smart Tag

    We do the same thing with the ReportToolbar except in this case we are selecting the target report viewer. That should be it!

    ASP.NET Report Viewer

    Summary

    Hope this was helpful! The main idea was that the data, the layout, and the presentation were all separate logical concepts (and in fact separate projects). If these concepts are kept separate there is nothing keeping you from swapping out data representations as well as client representations (i.e. now we want a Silverlight XPO report etc).

    As always, if there are any comments and/or questions, feel free to get a hold of me!

    Seth Juarez
    Email: sethj@devexpress.com
    Twitter: @SethJuarez

    Want The Best Reporting Tool Ever?

    Get The No-Compromise Reporting Tool for WinForms, ASP.NET, Silverlight and WPF! - Native integration with DevExpress WinForms and ASP.NET Controls, unequalled design-time productivity, industrial-grade features. Try a fully-functional version of DXperience for free now: http://www.devexpress.com/Downloads/NET/

    Let us know what you think of our Reporting Suite by rating it in the VS Gallery!

    Follow SethJuarez on Twitter

Next page »
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.