原創(chuàng)|使用教程|編輯:鄭恭琳|2019-09-18 11:39:15.933|閱讀 1561 次
概述:分組報(bào)告是數(shù)據(jù)分析所必需的。但是當(dāng)有大量數(shù)據(jù)并且不需要全部顯示時(shí),帶有分組的常規(guī)報(bào)告變得麻煩且多余。您希望為此類案例找到通用解決方案嗎?這里正好有一個(gè)。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
分組報(bào)告是數(shù)據(jù)分析所必需的。但是當(dāng)有大量數(shù)據(jù)并且不需要全部顯示時(shí),帶有分組的常規(guī)報(bào)告變得麻煩且多余。您希望為此類案例找到通用解決方案嗎?這里正好有一個(gè)。
帶有下拉列表的報(bào)告本質(zhì)上是一個(gè)包含分組數(shù)據(jù)的報(bào)告,但能夠通過鼠標(biāo)單擊隱藏或顯示組中的數(shù)據(jù)。它不僅非常方便,而且美觀。畢竟,報(bào)告成為一個(gè)交互式對(duì)象。當(dāng)用戶可以參與信息顯示時(shí),用戶會(huì)很高興。
考慮如何制作此類報(bào)告的示例。首先,與Master-Detail主從報(bào)表一樣(點(diǎn)擊這里查看如何制作Master-Detail主從報(bào)表>>),我們需要一個(gè)包含鏈接表的數(shù)據(jù)源。假設(shè)我們有兩個(gè)表:客戶和訂單。
一個(gè)客戶可以做很多訂單——一對(duì)多的關(guān)系。我們加上吧。單擊Actions按鈕,然后從下拉列表中選擇New Relation ...
父表是主表,然后選擇“customer”。子表分別是“orders”。在“customer”中有一個(gè)主鍵CustNo,在列表中選擇它。在“orders”中有一個(gè)外鍵CustNo,也選擇它。
結(jié)果,我們獲得了連接:
現(xiàn)在讓我們開始創(chuàng)建報(bào)告模板。添加一個(gè)頻段“group header”。在它上面我們將放置鏈接中的字段:“orders.customer.Company”、“orders.customer.Addr1”、“orders.customer.Phone”、“orders.customer.Contact”。
除了這些字段之外,我們還要為此頻段添加一個(gè)復(fù)選框控件。在CheckedSymbol屬性中,選擇Plus,然后選擇UncheckedSymbol - Minus。
添加“orders”表中的字段:OrderNo、SaleDate、PaymentMethod、AmountPaid到“Data”頻段。另外,為數(shù)據(jù)和字段標(biāo)題添加標(biāo)題區(qū):
雙擊組標(biāo)題“Headline”。選擇要分組的字段:
現(xiàn)在選擇我們之前添加的復(fù)選框。給它一個(gè)Hyperlink屬性:
選擇“Group Header”區(qū)域并為其創(chuàng)建BeforePrint事件處理程序:
private void GroupHeader1_BeforePrint(object sender, EventArgs e) { string groupName = (String)Report.GetColumnValue("orders.customer.Company"); // get the group name bool groupVisible = expandedGroups.Contains(groupName); // Check group visibility DataHeader1.Visible = groupVisible; Data1.Visible = groupVisible;// Set the visibility of data in accordance with the visibility of the group GroupFooter1.Visible = groupVisible;// Set the visibility of the basement of the group in accordance with the visibility of the group CheckBox1.Checked = !groupVisible;// Set the state of the flag depending on the visibility of the group }
還要向類添加擴(kuò)展組列表:
private List expandedGroups = new List();
讓我們回到我們的復(fù)選框。為此,創(chuàng)建一個(gè)Click事件處理程序:
private void CheckBox1_Click(object sender, EventArgs e) { string groupName = (sender as CheckBoxObject).Hyperlink.Value; // We get the name of the group from the hyperlink if (expandedGroups.Contains(groupName)) // If the list of visible groups contains the selected group expandedGroups.Remove(groupName); // Then remove the selected from the list of visible groups. else expandedGroups.Add(groupName); // Otherwise add the group to the list of visible Report.Refresh(); // Update Report }
以預(yù)覽模式運(yùn)行報(bào)告:
現(xiàn)在點(diǎn)擊任何加號(hào):
當(dāng)您單擊減號(hào)時(shí)會(huì)分組折疊。大神們都表示同意,這樣確實(shí)很方便。
產(chǎn)品介紹 | 下載試用 | 優(yōu)惠活動(dòng) |
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn