Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A Tutorial For Microsoft Report In WinForm Applications

I am using Microsoft Report in My WinForm Application Project.I am some problem with expressions and group and even filters and many thing else.I am looking for a compelete tutorial for Microsoft Report.But I didn't found any tutorial until now.Can you help me to find a tutorial?

I have found this.Tell me if u know better.Thanks

like image 459
Saleh Avatar asked May 25 '11 11:05

Saleh


People also ask

What is Microsoft WinForms?

Windows Forms (WinForms) is a free and open-source graphical (GUI) class library included as a part of Microsoft . NET, . NET Framework or Mono Framework, providing a platform to write client applications for desktop, laptop, and tablet PCs.

What is Windows application in C#?

Windows Forms is a Graphical User Interface(GUI) class library which is bundled in . Net Framework. Its main purpose is to provide an easier interface to develop the applications for desktop, tablet, PCs. It is also termed as the WinForms.


2 Answers

Creating the Client Report Definition file (RDLC) Add a folder called “RDLC”. This will hold our RDLC report. enter image description here

Right click on the RDLC folder, select “Add new item..” and add an “RDLC” name of “Products”. We will use the “Report Wizard” to walk us through the steps of creating the RDLC enter image description here

In the next dialog, give the dataset a name called “ProductDataSet”. Change the data source to “NorthwindReports.DAL” and select “ProductRepository(GetProductsProjected)”. The “Data Source” may show up empty. To get it populated, make sure your project is compiled and there is an index.aspx file in the root folder. This may be a bug.

The fields that are returned from the method are shown on the right. Click next. enter image description here

Drag and drop the ProductName, CategoryName, UnitPrice and Discontinued into the Values container. Note that you can create much more complex grouping using this UI. Click Next. enter image description here

Most of the selections on this screen are grayed out because we did not choose a grouping in the previous screen. Click next. enter image description here

Choose a style for your report. Click next. enter image description here

The report graphic design surface is now visible. Right click on the report and add a page header and page footer. enter image description here

With the report design surface active, drag and drop a TextBox from the tool box to the page header. Drag one more textbox to the page header. We will use the text boxes to add some header text as shown in the next figure. enter image description here

You can change the font size and other properties of the textboxes using the formatting tool bar (marked in red). You can also resize the columns by moving your cursor in between columns and dragging. enter image description here

Adding Expressions

Add two more text boxes to the page footer. We will use these to add the time the report was generated and page numbers. Right click on the first textbox in the page footer and select “Expression”. enter image description here

Add the following expression for the print date (note the = sign at the left of the expression in the dialog below) enter image description here

"© Northwind Traders " & Format(Now(),"MM/dd/yyyy hh:mm tt") Right click on the second text box and add the following for the page count.

Globals.PageNumber & " of " & Globals.TotalPages Formatting the page footer is complete.

We are now going to format the “Unit Price” column so it displays the number in currency format. Right click on the [UnitPrice] column (not header) and select “Text Box Properties..”

enter image description here

Under “Number”, select “Currency”. Hit OK.

enter image description here

Adding a chart

With the design surface active, go to the toolbox and drag and drop a chart control. You will need to move the product list table down first to make space for the chart contorl. The document can also be resized by dragging on the corner or at the page header/footer separator.

enter image description here

In the next dialog, pick the first chart type. This can be changed later if needed. Click OK. The chart gets added to the design surface.

enter image description here

Click on the blue bars in the chart (not legend). This will bring up drop locations for dropping the fields. Drag and drop the UnitPrice and CategoryName into the top (y axis) and bottom (x axis) as shown below. This will give us the total unit prices for a given category. That is the best I could come up with as far as what report to render, sorry :-) Delete the legend area to get more screen estate.

enter image description here

Resize the chart to your liking. Change the header, x axis and y axis text by double clicking on those areas.

enter image description here

We made it this far. Let’s impress the client by adding a gradient to the bar graph :-) Right click on the blue bar and select “Series properties”.

enter image description here

Under “Fill”, add a color and secondary color and select the Gradient style.

enter image description here

We are done designing our report. In the next section you will see how to add the report to the report viewer control, bind to the data and make it refresh when the filter criteria are changed.

For .cs file follow this link : Click here

For sub report follow this link : Click here for sub report details

For Common rdlc expression follow this link Click here

like image 171
yeasir007 Avatar answered Oct 16 '22 06:10

yeasir007


http://www.c-sharpcorner.com/UploadFile/robo60/StandaloneRDLCReports11142007183516PM/StandaloneRDLCReports.aspx

like image 21
Rached N. Avatar answered Oct 16 '22 06:10

Rached N.