2017-01-10 1 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

데이터는 세부 밴드 설정을 사용하여 각 행을 렌더링합니다. 설정에는 Detail Band에 추가 된 구성 요소뿐만 아니라 Detail Band 높이도 포함됩니다. 선 사이의 간격을 줄이려면 DetailBand.HeightF 속성을 더 작은 값으로 설정하십시오.

+0

그리고이 문제는 BeforePrint 메서드에서 발생합니다. 맞습니까? –

+0

XtraReport 생성자 또는 Visual Report Designer에서이 설정을 변경할 수 있습니다. – Uranus

관련 문제