Spread Windows Forms 6.0 Product Documentation
Setting a List Box Cell
Support Options
Spread Windows Forms 6.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Graphical Cell Types > Setting a List Box Cell

Glossary Item Box

You can use a list box cell to display a list -- allowing the user to select from the displayed list. You can specify the list of items, whether to include icons to appear along with text, the number that is displayed at any time, and other aspects of the display.

Text only

Text and icon

List box with three text-only choices

List box with three choices with text and images (icons)

To create a cell that acts like a list box, use the ListBoxCellType class. Create a list box cell using the procedures described below.

Customizing the List Appearance

Here is a summary of the appearance properties that you can use to customize the list box.

Property

Description

EditorValue

Set what value is written to the underlying data model.

ImageList

Set an image list for displaying icons along with text in the list.

ItemHeight

Set the height for each item in the list.

ItemData

Set item data, which is different from the items that are displayed, to use for the list.

Items

Set items to use for the list.

SubEditor

Set the subeditor.

See Also

For a complete list of the properties and methods of this cell type, refer to the ListBoxCellType class. For information on the combo box (which includes both a list box and an editable area), refer to Setting a Combo Box Cell.

For more information on other graphical cell types, refer to Working with Graphical Cell Types.

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 ListBox 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 a list box cell by creating an instance of the ListBoxCellType class.
  2. Specify the items in the list that appear as part of the list box. You can either use the Items property of the ListBoxCellType class or define a string and pass that in when creating the instance of the class.
  3. Assign the list box cell type to a cell or range of cells by setting the CellType property for a cell, column, row, or style to the ListBoxCellType object.

Example

C# Copy Code
FarPoint.Win.Spread.CellType.ListBoxCellType listcell = new FarPoint.Win.Spread.CellType.ListBoxCellType(); 

listcell.ImageList = ImageList1;
 
listcell.ItemData = new string[] { "One", "Two", "Three"};
 
listcell.Items = new string[] {"One","Two","Three"};
 
listcell.ItemHeight = 40;
 
fpSpread1.ActiveSheet.Cells[0, 0].CellType = listcell;
 
VB Copy Code
Dim listcell As New FarPoint.Win.Spread.CellType.ListBoxCellType()
 
listcell.ImageList = ImageList1
 
listcell.ItemData = New String() {"One", "Two", "Three"}
 
listcell.Items = New String() {"One", "Two", "Three"}
 
listcell.ItemHeight = 40
 
FpSpread1.ActiveSheet.Cells(0, 0).CellType = listcell
 

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 ListBox 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 ListBox. 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.
© 2002-2012 ComponentOne, a division of GrapeCity. All Rights Reserved.