-1

我有一个 GridControl,其数据源是一个 DataTable。DataTable 有两列,其中一列包含位图。GridView 的 RowAutoHeight 属性设置为 true 并且 GridControl 在表单中显示正常。但是如果我使用 ReportGenerator 生成 GridView 的报告并打印它,打印结果中单元格中的 Bitmap 非常小,打印时似乎 GridView.RowAutoHeight 不起作用。我尝试将 RepositoryItemPictureEdit 指定为编辑器,但没有帮助。

在此处输入图像描述

在此处输入图像描述

    private void PrintButtonClick(object sender, EventArgs e)
    {
        ReportGenerationOptions options = new ReportGenerationOptions();
        options.AutoFitToPageWidth = DefaultBoolean.True;

        var report = ReportGenerator.GenerateReport(gridView1, options);
        report.ShowPreviewDialog();

    }

    public BarCode CreateQrCode(String text, float sizeInMm)
    {
        BarCode barCode = new BarCode();
        barCode.Symbology = Symbology.QRCode;
        barCode.CodeText = text;
        barCode.BackColor = Color.White;
        barCode.ForeColor = Color.Black;
        barCode.RotationAngle = 0;
        barCode.CodeBinaryData = Encoding.Default.GetBytes(barCode.CodeText);
        barCode.Options.QRCode.CompactionMode = QRCodeCompactionMode.Byte;
        barCode.Options.QRCode.ErrorLevel = QRCodeErrorLevel.Q;
        barCode.Options.QRCode.Version = QRCodeVersion.AutoVersion;
        barCode.Options.QRCode.ShowCodeText = false;
        var g = this.CreateGraphics();
        barCode.DpiX = g.DpiX;
        barCode.DpiY = g.DpiY;
        barCode.Module = 1;
        barCode.Unit = GraphicsUnit.Millimeter;
        barCode.ImageHeight = sizeInMm;
        barCode.ImageWidth = sizeInMm;
        return barCode;
    }

    private void FormLoad(object sender, EventArgs e)
    {
        table.Columns.Add("Text", typeof(String));
        table.Columns.Add("QR Code", typeof(Image));
        gridControl1.DataSource = table;

        foreach (DataColumn tableColumn in table.Columns)
        {
            if (tableColumn.DataType == typeof(Image))
            {
                RepositoryItemPictureEdit pictureEdit = gridControl1.RepositoryItems.Add("PictureEdit") as RepositoryItemPictureEdit;
                pictureEdit.SizeMode = PictureSizeMode.Zoom;
                pictureEdit.NullText = " ";
                gridView1.Columns[tableColumn.ColumnName].ColumnEdit = pictureEdit;
                gridControl1.RepositoryItems.Add(pictureEdit);
            }
        }

        table.Rows.Add("foo", CreateQrCode("foo", 30).BarCodeImage);
        table.Rows.Add("bar", CreateQrCode("bar", 30).BarCodeImage);
    }
4

1 回答 1

1

从 DevExpress 支持中心我得到解决方案:使用

gridView1.ShowPrintPreview();

代替

ReportGenerationOptions options = new ReportGenerationOptions();
options.AutoFitToPageWidth = DefaultBoolean.True;

var report = ReportGenerator.GenerateReport(gridView1, options);
report.ShowPreviewDialog();
于 2019-08-25T01:11:42.227 回答