Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Graphical Cell Types > Setting a Barcode Cell |
You can display a barcode graphic in barcode cell. Various barcode types are available such as barcodes that are used in retail, the post office, etc. You can set various height and width properties for the barcode display.
You use the BarCodeCellType class to set the barcode cell and its properties. Create a barcode cell using the following procedure.
You can customize the barcode cell by using these properties:
Property |
Description |
---|---|
AcceptsCheckDigit |
Set whether to accept the check digit in the input. |
AdjustSize |
Set whether the barcode adjusts its size based on the barcode size. |
AutoStretch |
Set whether the size is based on the cell size. |
BarAdjust |
Set whether to fine tune the width of the barcode. |
BarCodePadding |
Set the left side and right side padding of the barcode. |
BarSize |
Set the height and width of the barcode. |
DisplayCheckDigit |
Set whether the check digit is available for the barcode. |
DisplayMode |
Set whether the barcode draws a barcode image. |
FixedLength |
Set the number of the fixed digits of the value of the barcode. |
IsFormulaValue |
Determine whether the editor contains a formula. |
Message |
Set whether to display the custom message string below the barcode image (if the barcode type allows it). |
MessagePosition |
Set the alignment of the custom message below the barcode image. |
MessageValue |
Set a custom message to display below the barcode image. |
MinimumHeight |
Set the minimum height of entire barcode. |
ModuleSize |
Set the size of the barcode module. |
Resolution |
Set the resolution of the barcode. |
Rotation |
Set the rotation angle of the barcode. |
Type |
Set the bar type of the barcode. |
Unit |
Set the unit of measure of the barcode. |
The FixedLength property only works with PostNet, ITF, or Code39 barcode types. The PostNet barcode option allows one less digit for the value than the setting for the FixedLength property.
Only the bar code types that have a line at the bottom to display the value can display a message (as set by the Message, MessagePosition, and MessageValue properties).
Here is a sample image of each of the supported barcode types that can be set with the Type property. The Jan8 type is similar to the EAN8 type. For more information about barcode types, refer to this article: https://en.wikipedia.org/wiki/International_Article_Number_(EAN).
Barcode Type | Sample Barcode Image |
---|---|
Code128 |
|
Code39 |
|
Code49 |
|
Code93 |
|
EAN128 |
|
ITF |
|
Jan13 |
|
Jan8 |
|
JapanesePostal |
|
NW7 |
|
PDF417 |
|
PostNet |
|
QRCode |
|
UPC |
You can display a customizable text message at the bottom of the barcode cell for several barcode types. This is supported for those barcode types that display the number value below the barcode image. (For example, PostNet, PDF417, JapanesePostal, and QRCode do not display a message.) In the example here, the value has been replaced with a text message. The code that generated this barcode image is shown below. The message is set using these properties: Message, MessagePosition, and MessageValue.
C# |
Copy Code
|
---|---|
FarPoint.Win.Spread.CellType.BarCodeCellType barc = new FarPoint.Win.Spread.CellType.BarCodeCellType(); barc.DisplayMode = FarPoint.Win.Spread.CellType.BarCodeDisplayMode.Image; barc.Message = true; barc.MessagePosition = FarPoint.Win.Spread.CellType.BarCode.MessagePosition.Left; barc.MessageValue = "Display This Instead of Value"; barc.Type = new FarPoint.Win.Spread.CellType.BarCode.UPC(); fpSpread1.ActiveSheet.Columns[0].Width = 220; fpSpread1.ActiveSheet.Rows[0].Height = 100; fpSpread1.ActiveSheet.Cells[0, 0].CellType = barc; fpSpread1.ActiveSheet.Cells[0, 0].Value = 36000280753; |
VB |
Copy Code
|
---|---|
Dim barc As New FarPoint.Win.Spread.CellType.BarCodeCellType barc.DisplayMode = FarPoint.Win.Spread.CellType.BarCodeDisplayMode.Image barc.Message = True barc.MessagePosition = FarPoint.Win.Spread.CellType.BarCode.MessagePosition.Left barc.MessageValue = "Display This Instead of Value" barc.Type = New FarPoint.Win.Spread.CellType.BarCode.UPC FpSpread1.ActiveSheet.Columns(0).Width = 220 FpSpread1.ActiveSheet.Rows(0).Height = 100 FpSpread1.ActiveSheet.Cells(0, 0).CellType = barc FpSpread1.ActiveSheet.Cells(0, 0).Value = 36000280753 |
Note that some graphical elements in certain cell types are affected by XP themes (visual styles). Setting the VisualStyles property of the Spread component to "off" can allow visual customizations of those graphical cell types to work as expected. For more information, refer to Using XP Themes with the Component.
For more information on the properties and methods of this cell type, refer to the BarCodeCellType class.
C# |
Copy Code
|
---|---|
FarPoint.Win.Spread.CellType.BarCodeCellType brcdcell = new FarPoint.Win.Spread.CellType.BarCodeCellType(); FpSpread1.Sheets[0].Cells[0, 0].CellType = brcdcell; FpSpread1.Sheets[0].Cells[0, 0].Value = "12345"; |
VB |
Copy Code
|
---|---|
Dim brcdcell As New FarPoint.Win.Spread.CellType.BarCodeCellType FpSpread1.Sheets(0).Cells(0, 0).CellType = brcdcell FpSpread1.Sheets(0).Cells(0, 0).Value = "12345" |
Or right-click on the cell or cells and select Cell Type. From the list, select Barcode. In the CellType editor, set the properties you need. Click Apply.