Mini Kabibi Habibi
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Web;
/// <summary>
/// Summary description for XtraReport1
/// </summary>
public class XtraReport1 : DevExpress.XtraReports.UI.XtraReport {
public class DataObject {
public DataObject(int id, string field1, string field2) {
ID = id;
Field1 = field1;
Field2 = field2;
}
public int ID { get; set; }
public string Field1 { get; set; }
public string Field2 { get; set; }
}
public static XtraReport1 CreateSampleReport(int recordCount) {
ArrayList listDataSource = new ArrayList();
for(int i = 0; i < recordCount; i++)
listDataSource.Add(new DataObject(i, "Field" + i, "Bookmark" + i));
XtraReport1 report = new XtraReport1();
report.DataSource = listDataSource;
report.AddBoundLabel("ID", new Rectangle(100, 20, 100, 30), false);
report.AddBoundLabel("Field1", new Rectangle(200, 20, 100, 30), false);
report.AddBoundLabel("Field2", new Rectangle(300, 20, 100, 30), true);
return report;
}
private DevExpress.XtraReports.UI.DetailBand Detail;
private DevExpress.XtraReports.UI.TopMarginBand TopMargin;
private DevExpress.XtraReports.UI.BottomMarginBand BottomMargin;
private XRTable xrTable2;
private XRTableRow xrTableRow2;
private XRTableCell xrTableCell4;
private XRTableCell xrTableCell5;
private XRTableCell xrTableCell6;
private ReportHeaderBand ReportHeader;
private XRLabel xrLabel1;
private XRLabel xrLabel4;
private ReportFooterBand ReportFooter;
private DevExpress.XtraReports.Parameters.Parameter Field;
private XRLabel xrLabel2;
private GroupHeaderBand GroupHeader1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
public XtraReport1()
{
InitializeComponent();
//
// TODO: Add constructor logic here
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
public void AddBoundLabel(string bindingMember, Rectangle bounds, bool bookmark) {
// Create a label.
XRLabel label = new XRLabel();
// Add the label to the report's Detail band.
Detail.Controls.Add(label);
// Set its location and size.
label.Location = bounds.Location;
label.Size = bounds.Size;
// Bind it to the bindingMember data field.
label.DataBindings.Add("Text", DataSource, bindingMember);
if(bookmark)
label.DataBindings.Add("Bookmark", DataSource, bindingMember);
}
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
string resourceFileName = "XtraReport1.resx";
this.Detail = new DevExpress.XtraReports.UI.DetailBand();
this.xrTable2 = new DevExpress.XtraReports.UI.XRTable();
this.xrTableRow2 = new DevExpress.XtraReports.UI.XRTableRow();
this.xrTableCell4 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell5 = new DevExpress.XtraReports.UI.XRTableCell();
this.xrTableCell6 = new DevExpress.XtraReports.UI.XRTableCell();
this.TopMargin = new DevExpress.XtraReports.UI.TopMarginBand();
this.BottomMargin = new DevExpress.XtraReports.UI.BottomMarginBand();
this.ReportHeader = new DevExpress.XtraReports.UI.ReportHeaderBand();
this.xrLabel1 = new DevExpress.XtraReports.UI.XRLabel();
this.xrLabel4 = new DevExpress.XtraReports.UI.XRLabel();
this.ReportFooter = new DevExpress.XtraReports.UI.ReportFooterBand();
this.Field = new DevExpress.XtraReports.Parameters.Parameter();
this.GroupHeader1 = new DevExpress.XtraReports.UI.GroupHeaderBand();
this.xrLabel2 = new DevExpress.XtraReports.UI.XRLabel();
((System.ComponentModel.ISupportInitialize)(this.xrTable2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
//
// Detail
//
this.Detail.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
this.xrTable2});
this.Detail.HeightF = 48F;
this.Detail.Name = "Detail";
this.Detail.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
this.Detail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
//
// xrTable2
//
this.xrTable2.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top)
| DevExpress.XtraPrinting.BorderSide.Right)
| DevExpress.XtraPrinting.BorderSide.Bottom)));
this.xrTable2.LocationFloat = new DevExpress.Utils.PointFloat(0F, 10.00001F);
this.xrTable2.Name = "xrTable2";
this.xrTable2.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] {
this.xrTableRow2});
this.xrTable2.SizeF = new System.Drawing.SizeF(367F, 27.49999F);
this.xrTable2.StylePriority.UseBorders = false;
this.xrTable2.StylePriority.UseTextAlignment = false;
this.xrTable2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopCenter;
//
// xrTableRow2
//
this.xrTableRow2.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] {
this.xrTableCell4,
this.xrTableCell5,
this.xrTableCell6});
this.xrTableRow2.Name = "xrTableRow2";
this.xrTableRow2.StylePriority.UseTextAlignment = false;
this.xrTableRow2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
this.xrTableRow2.Weight = 11.5D;
//
// xrTableCell4
//
this.xrTableCell4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(214)))), ((int)(((byte)(211)))));
this.xrTableCell4.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
new DevExpress.XtraReports.UI.XRBinding("Text", null, "Items.ID")});
this.xrTableCell4.Name = "xrTableCell4";
this.xrTableCell4.StylePriority.UseBackColor = false;
this.xrTableCell4.Text = "xrTableCell4";
this.xrTableCell4.Weight = 0.2857142857142857D;
//
// xrTableCell5
//
this.xrTableCell5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(240)))));
this.xrTableCell5.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
new DevExpress.XtraReports.UI.XRBinding("Text", null, "Items.Field")});
this.xrTableCell5.Name = "xrTableCell5";
this.xrTableCell5.StylePriority.UseBackColor = false;
this.xrTableCell5.Text = "xrTableCell5";
this.xrTableCell5.Weight = 0.2857142857142857D;
//
// xrTableCell6
//
this.xrTableCell6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(225)))), ((int)(((byte)(232)))), ((int)(((byte)(220)))));
this.xrTableCell6.BookmarkParent = this.xrLabel2;
this.xrTableCell6.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
new DevExpress.XtraReports.UI.XRBinding("Text", null, "Items.Bookmark"),
new DevExpress.XtraReports.UI.XRBinding("Bookmark", null, "Items.Bookmark")});
this.xrTableCell6.Name = "xrTableCell6";
this.xrTableCell6.StylePriority.UseBackColor = false;
this.xrTableCell6.Text = "xrTableCell6";
this.xrTableCell6.Weight = 0.2857142857142857D;
//
// TopMargin
//
this.TopMargin.HeightF = 30F;
this.TopMargin.Name = "TopMargin";
this.TopMargin.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
this.TopMargin.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
//
// BottomMargin
//
this.BottomMargin.HeightF = 497F;
this.BottomMargin.Name = "BottomMargin";
this.BottomMargin.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
this.BottomMargin.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
//
// ReportHeader
//
this.ReportHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
this.xrLabel1});
this.ReportHeader.HeightF = 50F;
this.ReportHeader.Name = "ReportHeader";
//
// xrLabel1
//
this.xrLabel1.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold);
this.xrLabel1.ForeColor = System.Drawing.Color.Black;
this.xrLabel1.LocationFloat = new DevExpress.Utils.PointFloat(122.3333F, 10.00001F);
this.xrLabel1.Name = "xrLabel1";
this.xrLabel1.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.xrLabel1.SizeF = new System.Drawing.SizeF(122.3333F, 23F);
this.xrLabel1.StylePriority.UseFont = false;
this.xrLabel1.StylePriority.UseForeColor = false;
this.xrLabel1.StylePriority.UseTextAlignment = false;
this.xrLabel1.Text = " Header";
this.xrLabel1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
//
// xrLabel4
//
this.xrLabel4.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Bold);
this.xrLabel4.ForeColor = System.Drawing.Color.Black;
this.xrLabel4.LocationFloat = new DevExpress.Utils.PointFloat(122.3333F, 10.00001F);
this.xrLabel4.Name = "xrLabel4";
this.xrLabel4.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
this.xrLabel4.SizeF = new System.Drawing.SizeF(122.3333F, 23F);
this.xrLabel4.StylePriority.UseFont = false;
this.xrLabel4.StylePriority.UseForeColor = false;
this.xrLabel4.StylePriority.UseTextAlignment = false;
this.xrLabel4.Text = "Footer";
this.xrLabel4.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
//
// ReportFooter
//
this.ReportFooter.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
this.xrLabel4});
this.ReportFooter.HeightF = 43F;
this.ReportFooter.Name = "ReportFooter";
//
// Field
//
this.Field.Description = "Parameter";
this.Field.Name = "Field";
//
// GroupHeader1
//
this.GroupHeader1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
this.xrLabel2});
this.GroupHeader1.GroupFields.AddRange(new DevExpress.XtraReports.UI.GroupField[] {
new DevExpress.XtraReports.UI.GroupField("Group", DevExpress.XtraReports.UI.XRColumnSortOrder.Ascending)});
this.GroupHeader1.HeightF = 45.83333F;
this.GroupHeader1.Name = "GroupHeader1";
//
// xrLabel2
//
this.xrLabel2.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
new DevExpress.XtraReports.UI.XRBinding("Text", null, "Items.Group"),
new DevExpress.XtraReports.UI.XRBinding("Bookmark", null, "Items.Group")});
this.xrLabel2.LocationFloat = new DevExpress.Utils.PointFloat(0F, 10.00001F);
this.xrLabel2.Name = "xrLabel2";
this.xrLabel2.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
this.xrLabel2.SizeF = new System.Drawing.SizeF(100F, 23F);
this.xrLabel2.Text = "xrLabel2";
//
// XtraReport1
//
this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
this.Detail,
this.TopMargin,
this.BottomMargin,
this.ReportHeader,
this.ReportFooter,
this.GroupHeader1});
this.DataMember = "Items";
this.DisplayName = "Report";
this.Margins = new System.Drawing.Printing.Margins(100, 383, 30, 497);
this.PageColor = System.Drawing.Color.Transparent;
this.Parameters.AddRange(new DevExpress.XtraReports.Parameters.Parameter[] {
this.Field});
this.Version = "11.2";
this.DataSourceDemanded += new System.EventHandler<System.EventArgs>(this.XtraReport1_DataSourceDemanded);
((System.ComponentModel.ISupportInitialize)(this.xrTable2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
}
#endregion
private void XtraReport1_DataSourceDemanded(object sender, EventArgs e) {
XtraReport1 report = sender as XtraReport1;
report.XmlDataPath = HttpContext.Current.Server.MapPath("~\\App_Data\\ReportDataSource.xml");
}
}