C# 动态XtraReport在细节上为我提供了很多行间距

C# 动态XtraReport在细节上为我提供了很多行间距,c#,label,devexpress,richtext,xtrareport,C#,Label,Devexpress,Richtext,Xtrareport,我正在编写一个使用Excel文件动态创建发票的程序。一切正常,除了“报告详细信息”部分显示了很多行之间的间距,最多为2'间距。我正在使用绑定标签创建线条。我已经读到,使用xrichtext可以有所帮助,但实际上没有。你能帮帮我吗 报告: public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport { public XtraReport1() { InitializeComponen

我正在编写一个使用Excel文件动态创建发票的程序。一切正常,除了“报告详细信息”部分显示了很多行之间的间距,最多为2'间距。我正在使用绑定标签创建线条。我已经读到,使用xrichtext可以有所帮助,但实际上没有。你能帮帮我吗

报告:

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;
    }
}
 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();

    }
报告生成:

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;
    }
}
 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();

    }
private void按钮1\u单击(对象发送者,事件参数e)
{
内坎蒂达德;
字符串codigo,description;
双pU,pT;
ArrayList listBindingSource=新的ArrayList();
列表myList=dataGridView1.DataSource作为列表;
对于(int i=0;i
数据绑定XtraReport使用细节标注栏设置渲染每一行。设置不仅包括添加到详图标注栏的构件,还包括详图标注栏高度。若要减小行间距,请将该属性设置为较小的值。

数据绑定XtraReport使用“细节”标注栏设置渲染每一行。设置不仅包括添加到详图标注栏的构件,还包括详图标注栏高度。要减小行间距,请将属性设置为较小的值。

我猜这会出现在BeforePrint方法中,对吗?您可以在XtraReport构造函数中甚至在可视化报表设计器中更改此设置。我猜这会出现在BeforePrint方法中,正确吗?您可以在XtraReport构造函数中甚至在可视化报表设计器中更改此设置。