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 |
---|---|
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 |
---|---|
Set what value is written to the underlying data model. |
|
Set an image list for displaying icons along with text in the list. |
|
Set the height for each item in the list. |
|
Set item data, which is different from the items that are displayed, to use for the list. |
|
Set items to use for the list. |
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.
Using the Properties Window
- At design time, in the Properties window, select the Spread component.
- Select the Sheets property.
- Click the button to display the SheetView Collection Editor.
- In the Members list, select the sheet in which the cells appear.
- In the property list, select the Cells property and then click the button to display the Cell, Column, and Row Editor.
- Select the cells for which you want to set the cell type.
- In the property list, select the CellType property and choose the ListBox cell type.
- Expand the list of properties under the CellType property. Select and set these specific properties as needed.
- Click OK to close the Cell, Column, and Row Editor.
- Click OK to close the SheetView Collection Editor.
Using Code
- Define a list box cell by creating an instance of the ListBoxCellType class.
- 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.
- 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
- Select the cell or cells in the work area.
- 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.
- From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.