How to Create a Simple Report in Windows Forms Using Infragistics Reporting
Infragistics provides a complete cool set of products in its reporting library. In this post we will see how we can create a very simple report using Infragistics set of controls. This post assumes that you have already installed Infragistics Reporting on your system. If not, you can download it from here. Let’s get started –
- Open Visual Studio & create a new Windows project. I will name the project as IGReport1 (here IG stands for Infragistics)
- I have added a Report folder in my project to store all reports under same location. Then we add a new Infragistics Report to the project using “Add New Item”.
- Once the report is added, you will see all relevant libraries are automatically referenced by Infragistics in the project and the report would look something like below screenshot –
- Now, we will configure a data source for the report to display the data. To do so, we will either click on the center of the report that says “Add a Report Data Source or use Reporting Controls from the Toolbox to start designing a report” or we can do so via “View menu > Report Data Explorer”. They both open the same window. We will be using the “Report Data Explorer” approach.
- Click on the 1st icon as marked in Red above to add a new data source.
- Choose your type of Data Source and Click Next. We will use SQL Data Source for now.
- Define the connection to SQL using the “New Connection” button and click “Next”. You can also name the Connection String to whatever you want to.
- Once the connection is configured, the wizard displays you a list of all tables/views that you can use to build a query for retrieving data for the report. You can either select a table or use “SQL Builder” to create a new query. Also, you can name your data source to your choice. Once you have created the query, click Next.
- In the next screen, you can test your query results using the “Test Query” button. If you’re happy with the result set, click “Finish” else go back and modify the data
- After the data source has been configured, you would see the entire columns under “Report Data Explorer” as below
- Time to put the fields on the report. Just drag the data source , here ‘SqlDataSource1’ to the Report Body section and you’re done.
- You can also click on “Preview” button present at the bottom of the report designer to view the final report how it looks like. The one we created looks like below –
- Our Report part is done. Now, let us show this report on the Windows form. To show an Infragistics report in Windows Forms project, we will need another control provided by Infragistics named as “UltraReportViewer”. Let us add the control to our main form and configure it to display the report.
- Now, run the project and it will look something similar to the below one.
Hope you like this article. Keep learning and sharing!