How to add BarCode to DataBand - Creating a report by using code

How to add BarCode to DataBand by using the example from

https://github.com/FastReports/FastReport.Documentation/blob/master/CreatingReportUsingCode.md#creating-a-report-by-using-code

How to add BarCodeQR      

var barCodeQR = new FastReport.Barcode.BarcodeQR();

//Set barcode Text

       // add it to DataBand

       data1.Objects.Add(barCodeQR);

In the Visual Studio Designer it shows...

CS1503: Argument 1:cannot convert from 'FastReport.Barcode.BarcodeQR' to 'FastReport.Base'

Using Visual Studio Pro 2019, .NET 5

Comments

  • edited February 2021

    Thank you, that was very helpful...here's how I did the code in .NET 5

          //Create the BarcodeObject Base

          var barcodeObjectQRBase = new FastReport.Barcode.BarcodeObject

          {

            Name = "Barcode48",

            Left = FastReport.Utils.Units.Centimeters * 14f,

            //Barcode48.Left = 500;

            Top = FastReport.Utils.Units.Centimeters * 16.25f,

            Width = FastReport.Utils.Units.Centimeters * 4.25f,

            Height = FastReport.Utils.Units.Centimeters * 4.4f,

            AutoSize = false,

            Text = "www.google.com",

            ShowText = false,

            AllowExpressions = true

          };

          //Create the QRBarCode

          var barcodeQR = new FastReport.Barcode.BarcodeQR()

          { 

            ErrorCorrection = FastReport.Barcode.QRCodeErrorCorrection.L,

            Encoding = FastReport.Barcode.QRCodeEncoding.UTF8,

            QuietZone = true

          };

          //Set barcodeObjectQRBase to barcodeQR

          barcodeObjectQRBase.Barcode=barcodeQR;

          //Add to dataBand

          dataBand.Objects.Add(barcodeObjectQRBase);//In the coded example it was data1

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.