Dotnet Linear Barcode Windows
Forms Control Manual & Tutorial
Our Linear Barcode Control supports several linear barcode symbologies including Code 39, Extended Code 39, Code 128,
UCC/EAN-128,
Interleaved 2 of 5,
LOGMARS, Codabar,
UPC-A, UPC-E, MSI, EAN-8, EAN-13, Code 11, Code 93, Industrial 2 of 5 Planet and
POSTNET.
Our ActiveX Controls are easy to use "drag and drop" automation tools that
will work in any Windows application that supports ActiveX control technology.
Using our controls is a simple 3 step process:
Step 1 - download and unzip the control package
Download and unzip the package. We suggest you place the DLL in a local
directory such as C:\IDAutomation that is
easy to remember.
Step 2 - register the control in your application
After you have installed the control on your PC, you have to tell your
application where it is. We have examples below that should help you.
Microsoft Visual Basic .NET and C# .NET:
- Open your solution or project and display the form that you want to add the barcode
to. Choose View - Toolbox to display the Toolbox. Right-click on
the Toolbox and choose Customize Toolbox. Choose the .NET Framework
Components folder. Choose Browse and select the IDAutomation Linear
Barcode Control.

- After the control appears in the Toolbox, add it to your form.

- You can also choose Project - Add Reference if you do not wish to add it
to the form.
Printing from the control:
- To print the barcode or copy it to an image control, you may look at the examples
provided in the ZIP file or view the sample code below.
- This is a simple example of how we can print the barcode using C#.NET:
private void cmdPrint_Click(object sender,
System.EventArgs e)
{
PrintDocument prndoc = new PrintDocument();
prndoc.DocumentName = "Printing a Barcode";
prndoc.PrintPage += new
System.Drawing.Printing.PrintPageEventHandler(this.PrintDocumentOnPrintPage );
prndoc.Print();
}
private void PrintDocumentOnPrintPage(object sender, PrintPageEventArgs ppea )
{
Graphics grfx = ppea.Graphics;
System.Drawing.Imaging.Metafile myImage;
grfx.DrawString(this.Text, this.Font, Brushes.Black, 0, 0);
myImage = barcode1.Picture;
grfx.DrawImage(myImage, 0, 40);
return;
}
- This is a simple example of how we can print the barcode using VB.NET:
Private Sub cmdPrint_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click
Dim prndoc As PrintDocument = New PrintDocument()
prndoc.DocumentName = "Printing a Barcode"
AddHandler prndoc.PrintPage, New
System.Drawing.Printing.PrintPageEventHandler(AddressOf
PrintDocumentOnPrintPage)
prndoc.Print()
End Sub
Private Sub PrintDocumentOnPrintPage(ByVal sender As Object, ByVal ppea As
PrintPageEventArgs)
Dim grfx As System.Drawing.Graphics = ppea.Graphics
Dim myImage As System.Drawing.Imaging.Metafile
grfx.PageUnit = GraphicsUnit.Millimeter
grfx.PageScale = 1.0F
grfx.DrawString(Me.Text, Me.Font, Brushes.Black, 0, 0)
myImage = Barcode1.Picture
grfx.DrawImage(myImage, 0, 20)
End Sub
- This is a simple example of how we can send the barcode metafile to a
PictureBox in VB .NET:
Private Sub cmdDisplayMetafile_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles
cmdDisplayMetafile.Click
Dim myImage As System.Drawing.Imaging.Metafile
myImage = Barcode1.Picture
PictureBox1.Refresh()
Dim grfx As System.Drawing.Graphics =
PictureBox1.CreateGraphics()
grfx.DrawImage(myImage, 0, 0)
grfx.Dispose()
myImage = Nothing
grfx = Nothing
End Sub
Step 3 - adjust the properties of the control
After you insert the control in your application as described in step
2, you may adjust the properties of the control. To do this, you can change
the properties with program code or you
can right-click on the control and choose Properties.
This section explains the main configuration parameters of the control:
NOTE: Many of the barcode sizing parameters are calculated in CM
(centimeters). Some barcode measurements are determined in "mils", which are
1/1000 of an inch. You may use the following rules for your conversions:
- To
convert mils to CM, multiply the mils value by .00254.
For example, 12 mils * .00254 = .03 CM.
- To convert CM to mils, divide the CM value by 2.54. For example, .03 CM /
2.54 = 11.8 mils.
- To convert inches to CM, multiply the value in inches by 2.54.
- DataToEncode - this is the data that is to be encoded in the barcode.
If you connect the control to a control source, then the source will override
this field.
- SymbologyID - this is the type of
barcode to be used. The default is code 128. For more information on barcode
types, visit
our barcoding for beginners site.
- BarHeightCM - the height of the barcode in CM. Default is 1 CM.
- leftMarginCM - the space of the left margin in CM.
- XDimensionCM - width in centimeters of the narrow bars. The default is 0.03 CM which is about
.012" or 12 mils. You may need to increase this value if your scanner
cannot read barcodes with small X dimensions. If you have a high
quality laser or CCD scanner, you may decrease this value to obtain a
higher density barcode.
- ApplyTilde - in Code 128 auto, if set to "true", you can use the
format ~ddd to specify the ASCII code of the character to be encoded. Default is
off. For example, if you enter the following text in the Data field: ~029AB
you will actually be encoding GSAB Where GS is a delimiter ASCII
29 character. This can be used in a single string to encode GS and RS characters
(GS = ASCII 29 and RS = ASCII 30). Other commonly used ASCII codes are ~009 for
a tab and ~013 which is a return function. This property is only valid for Code
128 Auto.
- AddCheckDigit - automatically adds the check digit to the barcode.
The check digit is required for all symbologies except Code 39, Industrial 2
of 5 and Codabar. When using symbologies that do not require the check digit,
you may disable the check digit.
- AddCheckDigitToText - automatically adds the check digit that is
encoded in the barcode to the human readable text that is displayed.
- CodabarStartCharacter - the start character for CODABAR.
Valid values are "A", "B", "C" or "D".
- CodabarStopCharacter - the stop character for CODABAR.
Valid values are "A", "B", "C" or "D".
- Code128CharSet - the set of characters to be used in code128. Valid values are: AUTO,
A, B or C.
The default is AUTO. For more information on Code 128, review
our Code 128 FAQ.
- BackColor - the background color of the barcode.
- ForeColor - the color of the foreground text and bars in the barcode.
- FitControlToBarcode - if true will automatically size the control
canvas to fit the barcode at design or runtime.
- Orientation - indicates the orientation of the barcode. Valid values are 0
(normal), 90 (vertical),180 (inverted)
and 270 (inverted vertical).
- Picture - the method used to retrieve the metafile image. For
example: myImage = Barcode1.Picture - see the source code examples for
more information.
- Resolution - the source that is used to determine the resolution the
image is drawn to, which creates a more accurate barcode. Default is printer. If
custom is selected, the number residing in the ResolutionCustomDPI property will
determine the resolution.
- ShowText - if this value is yes or true, the human readable text will
be displayed with the barcode.
- TextMarginCM - the distance between the lower portion of the barcode
and the text.
- TopMarginCM - the top margin in CM.
- Wide2NarrowRatio - this is the wide to narrow ratio of symbologies
that only contain narrow and wide bars such as Code 39, Interleaved 2 of 5 and
MSI. Usually, this value is between 2 and 3. The default value is 2.
- UPCESystem - the encoding system to be used for UPC-E,
valid values are 0 and 1.
Symbology specific notes
UPC-A, UPC-E, EAN-8 and EAN-13
Enter the data to be encoded without any spaces or dashes. You can enter the
+2 and +5 add-on codes by just adding them to the end of the string. If the
check digit is added, it will be ignored and regenerated to ensure that the code
can be scanned. If you rotate the barcode by 270, you may need to increase the
top margin. For UPC-E, you must enter the full 11 or 12 digit UPC-A code and the
barcode will be compressed if possible.
POSTNET and PLANET
When using the POSTNET barcode, the XDimensionCM (Narrow Bar Width) of .05 CM should be used.
For barcodes to be acceptable to the US post offices, they must be between 22
and 24 bars per inch. Setting the XDimensionCM to .05 should produce about 23
bars per inch. You should adjust this setting for your printer if your results
are different.
Code 128
The "AUTO" character set setting for Code 128 will
automatically switch character sets in the barcode as necessary. To encode alpha-numeric UCC/EAN-128, the character set
is set to "AUTO" for automatic. Then, ASCII 202 or character Ê is
entered as the FNC1 before each AI. For example, the UCC number of (8100)
712345 (21) 12WH5678 should be entered as: Ê8100712345Ê2112WH5678.
In most cases the AIs will be properly represented in the human readable
text.
Review the Code
128 Data Sheet and FAQ for more information on this barcode.
Subscribe to our FREE
IDAutomation.com newsletter to
receive updates on new products and symbologies available from us as
well as industry news related to barcoding. We respect the privacy
of our visitors. |
Technical support
To obtain technical support for this product, please visit the
Dotnet Windows
Forms Technical Support Site.
You may also view our
product index to obtain a list of all products we offer.
Copyright © 2001 IDAutomation.com, Inc. All rights reserved. All trademarks
mentioned are the property of their respective owners.