




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
1、XtraReport 報表設計器沒能專門的屬性可以做到空行顯示,下面我們采用腳本的方法實現(xiàn)這種空行顯示的功能;1. 找到報表的FillEmptySpace 事件,選中XtraReport1【注:為報表的對象】 右健點擊“屬性”,在“Behavior”-> “Scripts”-> “Fill Empty Space”如下圖所示:點擊FillEmptySpace事件, “new” 一個新事件如圖所示:把下面的代碼拷貝進去:下面紅色的代碼為公共變量,this.table2為顯示數(shù)據(jù)的表格,具體的要看實際的對象。private void xtraReport1_FillEmptySpace
2、(object sender,DevExpress.XtraReports.UI.BandEventArgs e) XRTable table = this.table2; /根據(jù)要顯示數(shù)據(jù)的表格獲取相關的屬性值int pubheight = table.Rowstable.Rows.Count - 1.Height; /默認為設計時的/單元行的高度,如需調(diào)整高度,自行設置數(shù)值。如:int pubheight = 30; XRTable xrTable = new XRTable(); /新建填充的空白表 xrTable.Size = new Size(table.Width, e.Band.
3、Height-1); /設置添加空行表的大/小,注意要和上面顯示數(shù)據(jù)的表的寬度一樣。 xrTable.BorderWidth = table.BorderWidth; /根據(jù)顯示數(shù)據(jù)的表設置邊框的寬度 xrTable.Location = table.Location;xrTable.BorderColor = table.BorderColor; int SpaceRowCount = e.Band.Height / pubheight; XRTableRow xrRow = new XRTableRowSpaceRowCount; if (SpaceRowCount > 0) for
4、 (int i = 0; i < SpaceRowCount; i+) xrRowi = new XRTableRow(); xrRowi.Size = new Size(table.Width, pubheight); xrRowi.Location = new Point(table.Location.X, i * pubheight); /設置一行的邊框 xrRowi.Borders = (DevExpress.XtraPrinting.BorderSide)(DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrin
5、ting.BorderSide.Right) | DevExpress.XtraPrinting.BorderSide.Bottom); xrRowi.BorderWidth = 1; xrRowi.BorderColor = table.Rowstable.Rows.Count - 1.BorderColor; CreateCellArray(xrRowi,table,pubheight); xrTable.Rows.AddRange(xrRow); e.Band.Controls.Add(xrTable); e.Band.Controls.Add(xrTable); / <summa
6、ry> / 創(chuàng)建空白行的Cell /在XRTableRow中添加單元格 / </summary> / <param name="xrRow"></param> private void CreateCellArray(XRTableRow xrRow,XRTable table,int pubheight) XRTableRow row = table.Rowstable.Rows.Count - 1; /獲取最后一行 int Xmargin = 0; for (int i = 0; i < row.Cells.Count;
7、i+) XRTableCell xrcell = new XRTableCell(); xrcell.BorderWidth = 1; /下面是設置單元的邊框,根據(jù)實際情況設置 xrcell.Borders = (DevExpress.XtraPrinting.BorderSide)(DevExpress.XtraPrinting.BorderSide)( DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right | DevExpress.XtraPrinting.BorderSide.
8、Bottom); /xrcell.Width = Convert.ToInt32(row.Cellsi.WidthF); xrcell.WidthF = row.Cellsi.WidthF; xrcell.BackColor = row.Cellsi.BackColor; xrcell.Height = pubheight; if (i != 0) xrcell.Location = new Point(Convert.ToInt32(Xmargin + row.Cellsi.WidthF), 0); else xrcell.Location = new Point(0, 0); xrRow.
9、Cells.Add(xrcell); 上面代碼中 CreateCellArray 方法是創(chuàng)建空白行的單元格。2. 做一個實例:新建一個報表,如下所示:拖入表格控件,設置相關的屬性等,完成報表模板的樣式。如下所示:選中當前報表對象,如圖所示:找到“Behavior”-> “Scripts”-> “Fill Empty Space”,new 一個新的事件,如下所示:把上面說明的代碼中“CreateCellArray” 方法拷貝進去,目的為的就是創(chuàng)建新單元格。/ <summary> / 創(chuàng)建空白行的Cell /在XRTableRow中添加單元格 / </summary&
10、gt; / <param name="xrRow"></param> private void CreateCellArray(XRTableRow xrRow,XRTable table,int pubheight) XRTableRow row = table.Rowstable.Rows.Count - 1; /獲取最后一行 int Xmargin = 0; for (int i = 0; i < row.Cells.Count; i+) XRTableCell xrcell = new XRTableCell(); xrcell.Bor
11、derWidth = 1; /下面是設置單元的邊框,根據(jù)實際情況設置 xrcell.Borders = (DevExpress.XtraPrinting.BorderSide)(DevExpress.XtraPrinting.BorderSide)( DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right | DevExpress.XtraPrinting.BorderSide.Bottom); /xrcell.Width = Convert.ToInt32(row.Cellsi.Wi
12、dthF); xrcell.WidthF = row.Cellsi.WidthF; xrcell.Height = pubheight; if (i != 0) xrcell.Location = new Point(Convert.ToInt32(Xmargin + row.Cellsi.WidthF), 0); else xrcell.Location = new Point(0, 0); xrRow.Cells.Add(xrcell); 如下圖所示:然后把上面說明中的“報表對象_FillEmptySpace”里的內(nèi)容拷貝到報表里的xtraReport1_FillEmptySpace事件中
13、。內(nèi)容如下:XRTable table = this.table2; /根據(jù)要顯示數(shù)據(jù)的表格獲取相關的屬性值int pubheight = table.Rowstable.Rows.Count - 1.Height; /默認為設計時的/單元行的高度,如需調(diào)整高度,自行設置數(shù)值。如:int pubheight = 30; XRTable xrTable = new XRTable(); /新建填充的空白表 xrTable.Size = new Size(table.Width, e.Band.Height-1); /設置添加空行表的大/小,注意要和上面顯示數(shù)據(jù)的表的寬度一樣。 xrTable.B
14、orderWidth = table.BorderWidth; /根據(jù)顯示數(shù)據(jù)的表設置邊框的寬度 xrTable.Location = table.Location;xrTable.BorderColor = table.BorderColor; int SpaceRowCount = e.Band.Height / pubheight; XRTableRow xrRow = new XRTableRowSpaceRowCount; if (SpaceRowCount > 0) for (int i = 0; i < SpaceRowCount; i+) xrRowi = new
15、XRTableRow(); xrRowi.Size = new Size(table.Width, pubheight); xrRowi.Location = new Point(table.Location.X, i * pubheight); /設置一行的邊框 xrRowi.Borders = (DevExpress.XtraPrinting.BorderSide)(DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right) | DevExpress.XtraPrinting.Bor
16、derSide.Bottom); xrRowi.BorderWidth = 1; xrRowi.BorderColor = table.Rowstable.Rows.Count - 1.BorderColor; CreateCellArray(xrRowi,table,pubheight); xrTable.Rows.AddRange(xrRow); e.Band.Controls.Add(xrTable); e.Band.Controls.Add(xrTable); 如圖所示:然后,我們再調(diào)整腳本里面的細節(jié)問題:XRTable table = this.table2; /根據(jù)要顯示數(shù)據(jù)的表格獲取相關的屬性值int pubheight = table.Rowstable.Rows.Co
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 濕稻谷訂購合同范本
- 個人述職報告范文
- 個人求職簡歷中的自薦信
- 個人房屋抵押借款簡單的合同范本
- 下鄉(xiāng)扶貧工作計劃
- 大學計算機基礎模擬試題及答案
- 單位發(fā)包合同范本
- 制氧機購銷合同范本
- 北京小汽車租賃合同范本
- 賣貨合同范例001
- GB 9706.14-1997醫(yī)用電氣設備第2部分:X射線設備附屬設備安全專用要求
- 測繪安全生產(chǎn)專題培訓課件
- 心肺復蘇簡易呼吸器使用除顫儀使用
- 油缸裝配作業(yè)指導書
- 2022年濟南工程職業(yè)技術學院單招綜合素質(zhì)考試筆試試題及答案解析
- 初中數(shù)學競賽試題匯編
- 湖南非稅在線繳費操作步驟
- GB∕Z 27735-2022 野營帳篷
- 高分子材料研究方法 X 射線法
- 【課件】第二單元第三節(jié)漢族民歌課件-2021-2022學年高中音樂人音版(2019)必修音樂鑒賞
- 高中人音版必修 音樂鑒賞20人民音樂家課件
評論
0/150
提交評論