Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Customizing Interaction with Cell Types > Working with Graphical Cell Types > Setting a Color Picker Cell |
You can allow your end user to select a color from a color picker using the color picker cell. A color picker cell displays a dialog for selecting a color. There are several options on the color dialog.
When a color picker cell is selected it displays a single color, which can appear either in a box or filling the entire area of the cell. Optionally text can be displayed.
When the cell is double-clicked, either the drop-down color picker is displayed or the pop-up color dialog is displayed. There are several options for the display of the color dialog. Here is the pop-up color dialog:
And here is the drop-down color picker:
To create a color picker cell, use the ColorPickerCellType class. Create a color picker cell using the procedure and example shown below.
The options for the color picker cell are in the ColorPickerStyle enumeration.
The color picker cell allows these customizations of the color dialog.
Property |
Description |
---|---|
AllowFullOpen |
Set whether to allow the color dialog to open fully to show the custom color selector. |
AnyColor |
Set whether the color dialog displays all available colors in the set of basic colors. |
Caption |
Set the text that appears in the cell (if any). |
CustomColors |
Set the custom colors shown in the color dialog. |
DialogShowing |
Set whether to automatically display the color dialog. |
DropDown |
Set whether to use the drop-down color picker (not the pop-up color dialog). |
FullOpen |
Set whether the color dialog opens fully to show controls used to create custom colors. |
SolidColorOnly |
Set whether the color dialog restricts users to selecting solid colors only. |
Style |
Set the style of the color dialog. |
UnknownText |
Set the text for an unknown color. |
UnknownTextStyle |
Set the style of the text for an unknown color. |
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 ColorPickerCellType class.
C# |
Copy Code
|
---|---|
FarPoint.Win.Spread.CellType.ColorPickerCellType cp = new FarPoint.Win.Spread.CellType.ColorPickerCellType(); cp.AllowFullOpen = true; cp.AnyColor = false; cp.CustomColors = new int[] {255, 190, 50}; cp.FullOpen = true; cp.Style = FarPoint.Win.Spread.CellType.ColorPickerStyle.BoxedWithText; FarPoint.Win.Spread.CellType.ColorPickerCellType c = new FarPoint.Win.Spread.CellType.ColorPickerCellType(cp); FpSpread1.ActiveSheet.Cells[0, 0].CellType = c; |
VB |
Copy Code
|
---|---|
Dim cp As New FarPoint.Win.Spread.CellType.ColorPickerCellType cp.AllowFullOpen = True cp.AnyColor = False cp.CustomColors = New Integer() {255, 190, 50} cp.FullOpen = True cp.Style = FarPoint.Win.Spread.CellType.ColorPickerStyle.BoxedWithText Dim c As New FarPoint.Win.Spread.CellType.ColorPickerCellType(cp) FpSpread1.ActiveSheet.Cells(0, 0).CellType = c |
Or right-click on the cell or cells and select Cell Type. From the list, select ColorPicker. In the CellType editor, set the properties you need. Click Apply.