Use of the devexpress report Control

Source: Internet
Author: User
1 Set the default printing paper and margins

Select Report-open the Properties window and set the default margin (margins) and default paper (paperkind ).

2 Repair Change Report Preview Default toolbar ( Winform )

 

 

Generally, the toolbar in the report preview can be used without modification. However, if you want to modify or add a new button to execute your own method, you need to modify the preview toolbar.

 

2.1Get default Toolbar

Devexpress. xtrabars.BarBar = report. printingsystem. previewformex. printbarmanager. Bars [0];

 

Printingsystem:The default print component of the current report, which is used to provide the default print preview dialog box and print function.

You can use printingsystem. previewforex. printbarmanager to obtain the toolbar and menu for setting the print preview window.

 

Obtain devexpress. xtrabars.BarThen you can add or delete the new baritem and menu.

 

2.2Add button

Bar. dockstyle = devexpress. xtrabars.Bardockstyle. Top;

Devexpress. xtrabars.BarbuttonitemPrintitem =NewDevexpress. xtrabars.Barbuttonitem(

Printingsystem. previewformex. printbarmanager,"Print", 1 );

Bar. additem (printitem );

 

 

2.3Hide unnecessary buttons

 

Example: Hide the print button

Printingsystem. setcommandvisibility (New Printingsystemcommand[] {

Printingsystemcommand. Printdirect,Printingsystemcommand. Print },Commandvisibility. None );

 

Setcommandvisibility() Method: Set the display and hide of menus and toolbar buttons.

Original method:

Public void setcommandvisibility (

Printingsystemcommand [] commands,

CommandvisibilityVisibility

);

Parameters

Commands

Devexpress. xtraprinting. printingsystemcommand

Specifies the command that can be executed in the preview file of the print system. (For details, click the link to see the help Documentation)

Visibility

Commandvisibility.

Specifies the visibility standard for printing system commands. (For details, click the link to see the help Documentation)

 

All

The toolbar items and menu items of these two commands are visible.

Menu

Obsolete; Use commandvisibility instead. The toolbar items and menu items of these two commands are visible.

None

 The toolbar buttons and menu items of these two commands are invisible.

Toolbar

Obsolete; Use commandvisibility instead. The toolbar items and menu items of these two commands are visible.

 

 

 

Use the developer express report Control

use the developer express report control:
when creating a report, select the xtrareport V3 class option in the new project, and name the report,
Click OK to jump out of its design interface.
it has three areas: pageheader [one band per page], detail, pagefooter [one band per page.
first, add a reportheader [one band per report]. In its blank area, right-click and Choose Insert band>
reportheader. If you do not need pageheader [one band per page], you can delete it.
the main difference between the two is that each page printed by pageheader [one band per page] displays the content of pageheader [one band per page]
. The reportheader [one band per report] is only displayed on the homepage. Other pages won't.
next is the main interface design problem. In its blank area, right-click and Choose Insert detail report> unbound.
it will jump out of a detailreport, which also has a detail1, mainly used to display the main content. Then add a column header to
display a main content, which is equivalent to a flag for easier viewing. You can right-click the button --> insert band --> groupheader.
A groupheader1 is displayed on detail1, or some data after the main content is displayed,
right-click the mouse and Choose Insert band> groupfooter.
if you want to display the other one at the same time, you can select detail and right-click the mouse --> insert detail report --> Unbound to jump out of another detailreport1, there is also a detail2 under it, add other same as above.

To bind the following data, you must bind the data in advance.
Detailreport. dataadapter = ADP 'data Adapter
Detailreport. datasource = DST 'dataset
Detailreport. datamember = "A" 'table

If you want to arrange the data in sequence, you need to use the events in it!
For example, cells in cell7 are in tables, but cells in other tables are bound to the data to be searched. If there are five data records, cells in cell 7 will not display their own, 5.

. Use the event of its own cell.
Private sub cell7_beforeprint (byval sender as object, byval e as system. Drawing. Printing. printeventargs) handles

Cell7.beforeprint
Dim lab as xrlabel = sender
Lab. Text = s's: the variable defines a global variable. The initial value is set to 1.
S + = 1
End sub

In another case, you may need to sum or calculate the number of columns in each row of data in the table.
'Evaluate the number
Dim xrsummary2 as devexpress. xtrareports. UI. xrsummary = new devexpress. xtrareports. UI. xrsummary
Cell32.databindings. Add ("text", DST, "A. ID ")
Xrsummary2.formatstring = "{0 }"
Xrsummary2.func = summaryfunc. Count
Xrsummary2.running = devexpress. xtrareports. UI. summaryrunning. Group
Me. cell32.summary = xrsummary2 '.

'sum
dim xrsummary1 as devexpress. xtrareports. UI. xrsummary = new devexpress. xtrareports. UI. xrsummary
me. cell33.databindings. addrange (New devexpress. xtrareports. UI. xrbinding () {New devexpress. xtrareports. UI. xrbinding ("text", DST, ". startmoney "," {0} ")})
xrsummary1.formatstring =" {0} "
xrsummary1.func = summaryfunc. sum
xrsummary1.running = devexpress. xtrareports. UI. summaryrunning. group
me. cell33.summary = xrsummary1

'cell binding
xrtablecell30.databindings. add ("text", DST, "vouchers. name ")
cell17.databindings. addrange (New devexpress. xtrareports. UI. xrbinding () {New devexpress. xtrareports. UI. xrbinding ("text", dst1, ". depositdate "," {0: yyyy/mm/dd} ")}) 'date format binding


'if you want to accumulate values in one of the two tables
' define two variables: interest1, interest2 is double type
'column of the first table
private sub cell25_beforeprint (byval sender as object, byval e as system. drawing. printing. printeventargs) handles cell25.beforeprint
dim lab as xrlabel = sender
dim value as double
value = convert. todouble (lab. text)
interest1 + = value ', the sum of all data in this column is obtained.
end sub

'column In the second table
private sub cell23_beforeprint (byval sender as object, byval e as system. drawing. printing. printeventargs) handles cell23.beforeprint
dim lab as xrlabel = sender
dim value as double
value = convert. todouble (lab. text)
interest2 + = value
end sub
'then, the values of the two columns are added to the cell cell19.
private sub cell19_beforeprint (byval sender as object, byval e as system. drawing. printing. printeventargs) handles cell19.beforeprint
me. cell19.text = interest1 + interest2
end sub

 

 

 

InWebPrint preview

InWebProgramBut it is relatively easy to use.

1AddReporttoolbarAndReportviewer.

ReporttoolbarProvides a set of tool commands for controlsReportviewerOperations performed by the view,ReporttoolbarThe most important attribute isReportviewerAttribute to specify a report view. For example:

ReportviewerUsed to showReportReport, you can useReportviewerOfReportSpecify attributes (select from the list), for example:

After setting, open the page in a browser and preview the report.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.