Spread Windows Forms 12.0 Product Documentation
Setting a Barcode Cell
Spread Windows Forms 12.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.

Bar Code

You use the BarCodeCellType class to set the barcode cell and its properties.

Customizing the Appearance

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).

Barcode Types

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

Code128 Barcode Type

Code39

Code39 Barcode Type

Code49

Code49 Barcode Type

Code93

Code93 Barcode Type

EAN128

EAN128 Barcode Type

ITF

ITF Barcode Type

Jan13

JAN13 Barcode Type

Jan8

Jan8 Barcode Type

JapanesePostal

JapanesePostal Barcode Type

NW7

NW7 Barcode Type

PDF417

PDF417 Barcode Type

PostNet

PostNet Barcode Type

QRCode

QRCode Barcode Type

UPC

UPC Barcode Type

Customizing the Message

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.

Barcode cell with message instead of value below barcode image

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.

Using the Properties Window

  1. At design time, in the Properties window, select the Spread component.
  2. Select the Sheets property.
  3. Click the button to display the SheetView Collection Editor.
  4. In the Members list, select the sheet in which the cells appear.
  5. In the property list, select the Cells property and then click the button to display the Cell, Column, and Row Editor.
  6. Select the cells for which you want to set the cell type.
  7. In the property list, select the CellType property and choose the BarCode cell type.
  8. Expand the list of properties under the CellType property. Select and set these specific properties as needed.
  9. Click OK to close the Cell, Column, and Row Editor.
  10. Click OK to close the SheetView Collection Editor.

Using Code

  1. Define the barcode cell by creating an instance of the BarCodeCellType class.
  2. Specify the properties of the barcode cell.
  3. Assign the barcode cell to a cell or range of cells by setting the CellType property for a cell, column, row, or style to the BarCodeCellType object.

Example

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"

Using the Spread Designer

  1. Select the cell or cells in the work area.
  2. In the property list, in the Misc category, select CellType. From the drop-down list, choose the BarCode cell type. Now expand the CellType property and various properties are available that are specific to this cell type. Select and set those properties as needed.

    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.

  3. From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.
See Also