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 for the color dialog.
When a color picker cell is selected it displays a single color, which can appear either in a box, as shown in the following image, 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. The following figure shows the pop-up color dialog:
The following figure shows 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 | Sets whether to allow the color dialog to open fully to show the custom color selector. |
AnyColor | Sets whether the color dialog displays all available colors in the set of basic colors. |
Caption | Sets the text that appears in the cell (if any). |
CustomColors | Sets the custom colors shown in the color dialog. |
DialogShowing | Sets whether to display the color dialog automatically. |
DropDown | Sets whether to use the drop-down color picker (not the pop-up color dialog). |
FullOpen | Sets whether the color dialog opens fully to show controls used to create custom colors. |
SolidColorOnly | Sets whether the color dialog restricts users to selecting solid colors only. |
Style | Sets the style of the color dialog. |
UnknownText | Sets the text for an unknown color. |
UnknownTextStyle | Sets the style of the text for an unknown color. |
The following figure illustrates the color dialog when it is set to fully open.
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.
This example creates a color picker cell.
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.