2017-01-10 4 views
0

Excelファイルを使用して請求書を動的に作成するプログラムを作成しています。レポートの詳細セクションに行間の間隔が2インチ以下になることを除いて、すべて正常に機能します。私は行を作成するためにバインドされたラベルを使用しています。私はXRRichTextを使ってそれが助けになることがあることを読んだが、そうではなかった。手伝ってくれませんか?Dynamic XtraReportは、行間に多くのスペースを与えます。

レポート:

public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport 
{ 
    public XtraReport1() 
    { 
     InitializeComponent(); 
    } 

    public void AddBoundLabel(String bindingMember, Rectangle bounds) 
    { 
     XRLabel label = new XRLabel(); 
     Detail.Controls.Add(label); 

     label.Font = new Font("Arial", 8); 
     label.Location = bounds.Location; 
     label.Size = bounds.Size; 
     label.DataBindings.Add("Text", null, bindingMember); 
     label.CanGrow = true; 
     label.CanShrink = true; 
     label.HeightF -= 50; 
     label.Padding = 0; 
    } 

    private void xrLabel_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) 
    { 
     XRRichText label = sender as XRRichText; 
     e.Cancel = true; 

     label.HeightF = 1 ; 
     label.Padding = 0; 
    } 
} 

レポート生成:XtraReportバインド

private void button1_Click(object sender, EventArgs e) 

    { 
     int cantidad; 
     string codigo, descripcion; 
     double pU, pT; 
     ArrayList listBindingSource = new ArrayList(); 
     List<String> myList = dataGridView1.DataSource as List<String>; 

     for(int i = 0; i< dataGridView1.Rows.Count; i++) 
     { 
      cantidad = Convert.ToInt16(dataGridView1.Rows[i].Cells[0].Value); 
      codigo = dataGridView1.Rows[i].Cells[1].Value.ToString(); 
      descripcion = dataGridView1.Rows[i].Cells[2].Value.ToString(); 
      pU = Convert.ToDouble(dataGridView1.Rows[i].Cells[3].Value); 
      pT = Convert.ToDouble(dataGridView1.Rows[i].Cells[4].Value); 
      listBindingSource.Add(new FacturaRecord(cantidad, codigo, descripcion, pU, pT)); 
     } 

     XtraReport1 report = new XtraReport1(); 
     report.Margins = new System.Drawing.Printing.Margins(100, 100, 25, 25); 
     report.DataSource = listBindingSource; 

     report.xrLabel6.Text = String.Format("Date: {0}", dateTimePicker1.Value.ToShortDateString()); 
     report.xrLabel11.Text = String.Format("Invoice Number {0}", textBox1.Text); 
     report.xrLabel12.Text = String.Format("Total: ${0}", sum); 

     report.AddBoundLabel("cantidad", new Rectangle(100, 20, 50, 5)); 
     report.AddBoundLabel("codigo", new Rectangle(150, 20, 100, 5)); 
     report.AddBoundLabel("descripcion", new Rectangle(250, 20, 200, 5)); 
     report.AddBoundLabel("precioUnitario", new Rectangle(500, 20, 50, 5)); 
     report.AddBoundLabel("precioTotal", new Rectangle(600, 20, 50, 5)); 

     ReportPrintTool printTool = new ReportPrintTool(report); 
     printTool.ShowPreviewDialog(); 

    } 

答えて

0

データは、詳細バンドの設定を使用して、各ラインをレンダリングします。設定には、詳細バンドに追加されたコンポーネントだけでなく、詳細バンドの高さも含まれます。行間の間隔を小さくするには、DetailBand.HeightFプロパティを小さい値に設定します。

+0

これはBeforePrintメソッドで正しいと思いますか? –

+0

この設定は、XtraReportコンストラクターまたはビジュアルレポートデザイナーでも変更できます。 – Uranus

関連する問題