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 a barcode cell. Various barcode types are available such as barcodes that are used in retail, for shipping, and so on. You can set height and width properties for the barcode display.
You use the BarCodeCellType class to set the barcode cell and its properties.
You can customize the barcode cell by using these properties:
Property | Description |
---|---|
AcceptsCheckDigit | Sets whether to accept the check digit in the input. |
AdjustSize | Sets whether the barcode adjusts its size based on the barcode size. |
AutoStretch | Sets whether the size is based on the cell size. |
BarAdjust | Sets whether to fine tune the width of the barcode. |
BarCodePadding | Sets the left side and right side padding of the barcode. |
BarSize | Sets the height and width of the barcode. |
DisplayCheckDigit | Sets whether the check digit is available for the barcode. |
DisplayMode | Sets whether the barcode draws a barcode image. |
FixedLength | Sets the number of the fixed digits of the value of the barcode. |
IsFormulaValue | Determines whether the editor contains a formula. |
Message | Sets whether to display the custom message string below the barcode image (if the barcode type allows it). |
MessagePosition | Sets the alignment of the custom message below the barcode image. |
MessageValue | Sets a custom message to display below the barcode image. |
MinimumHeight | Sets the minimum height of entire barcode. |
ModuleSize | Sets the size of the barcode module. |
Resolution | Sets the resolution of the barcode. |
Rotation | Sets the rotation angle of the barcode. |
Type | Sets the bar type of the barcode. |
Unit | Sets 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: http://www.gs1.org/barcodes.
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.
This example creates a bar code cell.
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.