Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Graphical Cell Types > Setting a Combo Box Cell |
You can use a combo box cell to display an editable drop-down list, allowing the user to type in values as well as choosing from a 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 whether the cell is editable by the user.
Text only | Text and icon |
---|---|
To create a cell that acts like a combo box, use the ComboBoxCellType class. Create a combo box cell using the following procedure.
Use the following appearance properties to customize the combo box.
Property | Description |
---|---|
BackgroundImage | Sets an image to paint in the background of the edit portion of the combo box. |
ButtonAlign | Sets where buttons are displayed. |
ImageList | Sets an image list for displaying icons along with text in the drop-down list in the combo box. |
ItemData | Sets item data, which is different from the items that are displayed, for the drop-down list in the combo box. |
Items | Sets items for the drop-down list in the combo box. |
ListAlignment | Sets the side of the cell on which the list aligns. |
ListOffset | Sets how many pixels to offset the list from the aligned edge of the cell. |
ListWidth | Sets the width (in pixels) of the drop-down list. |
MaxDrop | Sets the number of items to display at one time in the list portion. If there are more items than are displayed, a vertical scroll bar is displayed. |
MaxLength | Sets the maximum number of characters allowed in the combo box cell. |
Use the following operation properties to customize the combo box.
Property | Description |
---|---|
AcceptsArrowKeys | Sets how arrow keys are processed by the combo box control. |
AutoSearch | Sets how a list of items in a combo box is searched based on input of a character key. |
CharacterCasing | Sets the case of characters in the text cell. |
CharacterSet | Sets what characters to allow for the text cell. |
Editable | Sets whether you can type into the edit portion of the combo box. |
EditorValue | Sets what value is written to the underlying data model. |
ListControl | Sets the control to use for the list portion if you do not want to use the built-in list control in Spread. |
The Spread control has a ButtonDrawMode property for button cells and combo box cells. This property allows you to always show a button, or show buttons in the current column, row, or cell.
Use the following properties to customize the automatic completion feature in combo box cells when using the 2005 build of the component.
Property | Description |
---|---|
AutoCompleteCustomSource | Set the custom source (strings) for automatic completion of entries in the combo box. |
AutoCompleteMode | Set the mode for automatic completion of entries in the combo box. |
AutoCompleteSource | Set the source for automatic completion of entries in the combo box. |
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.
To display a text tip over a combo box cell, see the note in Displaying Text Tips in a Cell.
For more information on the properties and methods of this cell type, refer to the ComboBoxCellType class. For information on the multiple-column combo box, refer to Setting a Multiple-Column Combo Box Cell.
This example creates a combo cell.
C# |
Copy Code
|
---|---|
FarPoint.Win.Spread.CellType.ComboBoxCellType cmbocell = new FarPoint.Win.Spread.CellType.ComboBoxCellType(); cmbocell.Items = (new String[] {"January", "February", "March", "April", "May", "June"}); cmbocell.AutoSearch = FarPoint.Win.AutoSearch.SingleCharacter; cmbocell.Editable = true; cmbocell.MaxDrop = 4; fpSpread1.ActiveSheet.Cells[0, 0].CellType = cmbocell; |
VB |
Copy Code
|
---|---|
Dim cbstr As string( ) cbstr = new String() {"Jan", "Feb", "Mar", "Apr", "May", "Jun"} Dim cmbocell As New FarPoint.Win.Spread.CellType.ComboBoxCellType() cmbocell.Items = cbstr cmbocell.AutoSearch = FarPoint.Win.AutoSearch.SingleCharacter cmbocell.Editable = True cmbocell.MaxDrop = 4 FpSpread1.ActiveSheet.Cells(0, 0).CellType = cmbocell |
Or right-click on the cell or cells and select Cell Type. From the list, select ComboBox. In the CellType editor, set the properties you need. Click Apply.