Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Graphical Cell Types > Setting a List Box Cell |
You can use a list box cell to display a list, which allows 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 of items that are 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 following procedure.
Here is a summary of the appearance properties that you can use to customize the list box.
Property | Description |
---|---|
EditorValue | Sets what value is written to the underlying data model. |
ImageList | Sets an image list for displaying icons along with text in the list. |
ItemHeight | Sets the height for each item in the list. |
ItemData | Sets item data, which is different from the items that are displayed, to use for the list. |
Items | Sets 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.
This example creates a list box cell and uses images from an image list control.
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; fpSpread1.ActiveSheet.Rows[0].Height = 120; |
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 FpSpread1.ActiveSheet.Rows(0).Height = 120 |
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.