Blogs

DevExpress Data Blog

This blog features all things having to do with data shaping, layout, and presentation!

September 2011 - Posts

  • 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

LIVE CHAT

Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

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