This article provides a simple way to produce Code 3 of 9 Barcodes through C#. While there are many third-party controls that offer this functionality, it is just as simple to integrate your barcodes using readily availabl barcode TrueType fonts.
The source code included in the zip file contains two classes, one is the UI to retrieve the barcode info (frmBarcode.cs), and the other is the barcode printing class (BarcodePrinter.cs). Also, for this example to work, you will need to add the TrueType Font for the barcode that is included in the source code.
I chose the 3 of 9 Barcode style (also known as a Code 39) for this example for two reasons, it is not fixed with, and it allows for both Alpha and Numeric characters. With the font included here, an asterisk (*) is used as both the start and the stop character for the barcode symbology. Without the (*) on both ends, the barcode will not scan.
For my example, I have set the barcode font size to 15 point. You are free to adjust is as needed for your application, but keep in mind that a small barcode may not be readable by all scanners and some wedge type scanners cannot read extremely wide barcodes. You will need to determine the proper size for your application.
Please note that I have set the #if DEBUG directive so that the application will only print to the PrintPreview Dialog during testing. Doing this saves greatly in both time and printer costs.
The human readable element of the barcode here is optional.