原創(chuàng)|其它|編輯:郝浩|2012-09-18 11:43:12.000|閱讀 686 次
概述:本教程描述了創(chuàng)建drill-down report鉆取報(bào)表的步驟。在這個(gè)例子中,我們將用到使用Detail Report bands細(xì)節(jié)報(bào)表區(qū)域創(chuàng)建的master-detail report主從報(bào)表,每個(gè)類(lèi)別的細(xì)節(jié)部分可以通過(guò)點(diǎn)擊一個(gè)適當(dāng)?shù)逆溄诱归_(kāi)/折疊。附上圖片和代碼說(shuō)明。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
本教程描述了運(yùn)用DevExpress XtraReports創(chuàng)建drill-down report鉆取報(bào)表的步驟。在這個(gè)例子中,我們將用到使用Detail Report bands細(xì)節(jié)報(bào)表區(qū)域創(chuàng)建的master-detail report主從報(bào)表,每個(gè)類(lèi)別的細(xì)節(jié)部分可以通過(guò)點(diǎn)擊一個(gè)適當(dāng)?shù)逆溄诱归_(kāi)/折疊。
步驟如下:
1 使用Detail Report區(qū)域創(chuàng)建一個(gè)master-detail report主從復(fù)合結(jié)構(gòu)報(bào)表。
2 創(chuàng)建一個(gè)顯示/隱藏細(xì)節(jié)報(bào)表的鏈接,將標(biāo)簽拖放到報(bào)表的Detail細(xì)節(jié)區(qū)域上。
設(shè)置XRControl.Text的文本為Show Detail, XRControl.Name名稱(chēng)為lblShowHide,并設(shè)置 (DataBindings)Tag.Binding屬性為CategoryID數(shù)據(jù)字段.
3 執(zhí)行上述步驟后,可以得到如下報(bào)表。
4然后以如下的編程方式處理標(biāo)簽的BeforePrint,PreviewClick,PreviewMouseMove事件和DetailReport的BeforePrint事件:
C#
using System.Collections;
using System.Windows.Forms;
using System.Drawing.Printing;
using DevExpress.XtraReports.UI;
// ...
// Declare two string constants, to store the label's Text value.
const string sShowDetail = "Show Detail";
const string sHideDetail = "Hide Detail";
// Create an array containing IDs of the categories being expanded.
ArrayList expandedValues = new ArrayList();
// This function returns a value indicating whether a certain
// category's details should be expanded.
bool ShouldShowDetail(int catID) {
return expandedValues.Contains(catID);
}
private void lbShowHide_BeforePrint(object sender, PrintEventArgs e) {
XRLabel label = (XRLabel)sender;
// Choose the label's text.
if(ShouldShowDetail((int)label.Tag)) {
label.Text = sHideDetail;
}
else {
label.Text = sShowDetail;
}
}
private void DetailReport_BeforePrint(object sender, PrintEventArgs e) {
// Cancel the Detail Report band's printing if necessary.
e.Cancel = !ShouldShowDetail((int)GetCurrentColumnValue("CategoryID"));
}
private void lbShowHide_PreviewClick(object sender, PreviewMouseEventArgs e) {
// Obtain the category's ID stored in the label's Tag property.
int index = (int)e.Brick.Value;
// Determine whether the current category's details are shown.
bool showDetail = ShouldShowDetail(index);
// Toggle the visibility of the category's details.
if(showDetail) {
expandedValues.Remove(index);
}
else {
expandedValues.Add(index);
}
// Re-create a document to apply the changes.
CreateDocument();
}
// The following code changes the cursor to "hand" when it hovers the label,
// so that it behaves as a common link.
private void lbShowHide_PreviewMouseMove(object sender, PreviewMouseEventArgs e) {
Cursor.Current = Cursors.Hand;
}
VB
Imports System.Collections
Imports System.Windows.Forms
Imports System.Drawing.Printing
Imports DevExpress.XtraReports.UI
' ...
' Declare two string constants, to store the label's Text value.
Private Const sShowDetail As String = "Show Detail"
Private Const sHideDetail As String = "Hide Detail"
' Create an array containing IDs of the categories being expanded.
Private expandedValues As New ArrayList()
' This function returns a value indicating whether a certain
' category's details should be expanded.
Private Function ShouldShowDetail(ByVal catID As Integer) As Boolean
Return expandedValues.Contains(catID)
End Function
Private Sub lbShowHide_BeforePrint(ByVal sender As Object, ByVal e _
As PrintEventArgs) Handles lbShowHide.BeforePrint
Dim label As XRLabel = CType(sender, XRLabel)
' Choose the label's text.
If ShouldShowDetail(CInt(Fix(label.Tag))) Then
label.Text = sHideDetail
Else
label.Text = sShowDetail
End If
End Sub
Private Sub DetailReport_BeforePrint(ByVal sender As Object, ByVal e _
As PrintEventArgs) Handles DetailReport.BeforePrint
' Cancel the Detail Report band's printing if necessary.
e.Cancel = Not ShouldShowDetail(CInt(Fix(GetCurrentColumnValue("CategoryID"))))
End Sub
Private Sub lbShowHide_PreviewClick(ByVal sender As Object, ByVal e _
As PreviewMouseEventArgs) Handles lbShowHide.PreviewClick
' Obtain the category's ID stored in the label's Tag property.
Dim index As Integer = CInt(Fix(e.Brick.Value))
' Determine whether the current category's details are shown.
Dim showDetail As Boolean = ShouldShowDetail(index)
' Toggle the visibility of the category's details.
If showDetail Then
expandedValues.Remove(index)
Else
expandedValues.Add(index)
End If
' Re-create a document to apply the changes.
CreateDocument()
End Sub
' The following code changes the cursor to "hand" when it hovers the label,
' so that it behaves as a common link.
Private Sub lbShowHide_PreviewMouseMove(ByVal sender As Object, ByVal e _
As PreviewMouseEventArgs) Handles lbShowHide.PreviewMouseMove
Cursor.Current = Cursors.Hand
End Sub
鉆取報(bào)表就完成了。運(yùn)行打印預(yù)覽表單,并查看結(jié)果。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:外文翻譯