.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
The page you are viewing does not exist in the .NET Standard 2.0+ platform documentation. This link will take you to the parent topic of the current section.
.NET Core 3.0+

Getting Started

  • 3 minutes to read
IMPORTANT

You need a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.

Perform the steps below to get started with the Barcode Generation API.

  1. Create a new Windows Forms App (.NET Framework) project.

  2. Add references to the DevExpress.Docs.v19.2.dll and DevExpress.Data.v19.2.dll assemblies.

  3. Drop the Button and PictureBox items from the Toolbox onto the form.

  4. Add the following code to the method that handles the button's Click event.

    using System;
    using System.Drawing;
    using System.Text;
    using DevExpress.BarCodes;
    //...
    
    private void button1_Click(object sender, EventArgs e)
    {
        this.pictureBox1.Image = null;
    
        BarCode barCode = new BarCode();
        barCode.Symbology = Symbology.QRCode;
        barCode.CodeText = "https://www.devexpress.com/";
        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.ShowCodeText = false;
        barCode.DpiX = 72;
        barCode.DpiY = 72;
        barCode.Module = 2f;
    
        this.pictureBox1.Image = barCode.BarCodeImage;
    }
    
  5. Run the project and click the button. The PictureBox control displays the resulting QR code.

    Barcode_Result

  1. Start Microsoft Visual Studio and create a new Console Application (.NET Core) project.

  2. Install the DevExpress.WindowsDesktop.Document.Processor NuGet package.

  3. Right-click the project in the Solution Explorer and select Edit Project File.

    Office_NetCore_3_Edit_Project_File

    Change the project's SDK attribute to Microsoft.NET.Sdk.WindowsDesktop and set the UseWindowsForms option to true.

    <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
    
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.0</TargetFramework>
        <UseWindowsForms>true</UseWindowsForms>
      </PropertyGroup>
    </Project>
    
  4. Paste the code below in the Main method of the Program.cs file (Main procedure of the Module1.vb file for Visual Basic).

    using System.Drawing;
    using System.Text;
    using DevExpress.BarCodes;
    // ...
    
    static void Main(string[] args)
    {
      // Create a QR code.
      BarCode barCode = new BarCode();
      barCode.Symbology = Symbology.QRCode;
      barCode.CodeText = "https://www.devexpress.com";
      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.ShowCodeText = false;
      barCode.DpiX = 72;
      barCode.DpiY = 72;
      barCode.Module = 2f;
    
      // Save the barcode as an image.
      barCode.Save("BarCodeImage.png", System.Drawing.Imaging.ImageFormat.Png);
      // Open the image in the default viewer.
      Process.Start(new ProcessStartInfo("BarCodeImage.png") { UseShellExecute = true });
    }
    
  5. Run the project. The resulting image is shown below:

Barcode_Result_NetCore3

See Also