ActiveReports 6 Online Help
Use XML Data with Barcodes
Show AllShow All
Hide AllHide All

When you use an XML data source to supply data to the Barcode control, the control is unable to automatically detect the data type of the XML node. For this reason, you can use the DataType attribute of the XML node to specify string, double, or date time data.

If you have a numeric field with leading zeroes that you need to use with the Barcode control, specify a string DataType to avoid clipping the zeroes.

To specify a string DataType for an XML node and assign it to a barcode

These steps assume that you have already created a report viewer form project and added a report (NewActiveReport1 by default).

  1. In the design view of the viewer form, double-click the title bar to open the code view and create a Form Load event.
  2. If you are using Visual Basic, paste code like the following above the Form Load event to create a new instance of your report and access its events (in C#, the code is inside the event in the following step):

    To write the code in Visual Basic.NET

  3. Paste code like the following inside the Form Load event to create an XML data source, assign it to the report, access the report's FetchData event, and display the report in the viewer:

    To write the code in Visual Basic.NET

    To write the code in C#

  4. Paste code like the following below the Form Load event to create a FetchData event for the report, access the XML data source, and pass in the string DataType attribute:

    To write the code in Visual Basic.NET

    To write the code in C#

    Note: When you run this code, it transforms each <bcData>0003456</bcData> node into <bcData DataType="string">0003456</bcData>.

  5. Open the design view of NewActiveReport1 and from the ActiveReports 6 section of the Toolbox, drag a Barcode control and drop it onto the report.
  6. Barcode1 is selected in the Properties grid by default. In the DataField property enter . (a period) to assign the node to the barcode.
See Also

Concepts