---
id: "T:cAlgo.API.ColorPicker"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/ColorPicker/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# ColorPicker (class)

Represents the ColorPicker control.

Environments: Desktop supported · CLI not supported · Cloud not supported.

- CLI: Accepted without error but never displayed, so control events such as Click are never raised.
- Cloud: Accepted without error but never displayed, so control events such as Click are never raised.

## Definition

```csharp
public class ColorPicker : ControlBase
```

Available since cAlgo.API 5.1.

## Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo.Robots;

public partial class TestExample : Robot
{
   protected override void OnStart()
   {
       var colorPicker = new ColorPicker {SelectedColor = Color.FromHex("#eb4034"), IsStretched = true};

       var hexColorTextBox = new TextBox {Text = "#eb4034"};

       colorPicker.SelectedColorChanged += args => hexColorTextBox.Text = colorPicker.SelectedColor.ToHexString();

       var changeColorButton = new Button {Text = "Change Color"};

       changeColorButton.Click += args => colorPicker.SelectedColor = Color.FromHex(hexColorTextBox.Text);

       var panel = new StackPanel
       {
            Orientation = Orientation.Vertical,
            HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment = VerticalAlignment.Center
       };

       panel.AddChild(colorPicker);
       panel.AddChild(hexColorTextBox);
       panel.AddChild(changeColorButton);

       Chart.AddControl(panel);
   }
}
```

Python:

```python
import clr
clr.AddReference("cAlgo.API")
# Import cAlgo API types
from cAlgo.API import *
# Import trading wrapper functions
from robot_wrapper import *

class Test():
    def on_start(self):
        self.colorPicker = ColorPicker()
        self.colorPicker.SelectedColor = Color.FromHex("#eb4034")
        self.colorPicker.IsStretched = True

        self.hexColorTextBox = TextBox()
        self.hexColorTextBox.Text = "#eb4034"

        self.colorPicker.SelectedColorChanged += self.on_selected_color_changed

        changeColorButton = Button()
        changeColorButton.Text = "Change Color"
        changeColorButton.Click += self.on_change_color_button_clicked

        panel = StackPanel()
        panel.Orientation = Orientation.Vertical
        panel.HorizontalAlignment = HorizontalAlignment.Center
        panel.VerticalAlignment = VerticalAlignment.Center

        panel.AddChild(self.colorPicker)
        panel.AddChild(self.hexColorTextBox)
        panel.AddChild(changeColorButton)

        api.Chart.AddControl(panel)

    def on_selected_color_changed(self, args):
        self.hexColorTextBox.Text = args.ColorPicker.SelectedColor.ToHexString()

    def on_change_color_button_clicked(self, args):
        self.colorPicker.SelectedColor = Color.FromHex(self.hexColorTextBox.Text)
```

config.json:

```json
{
  "AccessRights": "None"
}
```

## Constructors

- `public ColorPicker()` — Initializes a new instance of the ColorPicker class. [details](https://help.ctrader.com/ctrader-algo/references/Controls/ColorPicker/Constructor/index.md)

## Properties

- `public bool IsStretched {get; set;}` — Gets or sets if color picker is stretched or not. [details](https://help.ctrader.com/ctrader-algo/references/Controls/ColorPicker/IsStretched/index.md)
- `public Color SelectedColor {get; set;}` — Gets or sets selected color. [details](https://help.ctrader.com/ctrader-algo/references/Controls/ColorPicker/SelectedColor/index.md)

## Events

- `public event Action<ColorPickerSelectedColorChangedEventArgs> SelectedColorChanged;` — Occurs when selected color is changed. [details](https://help.ctrader.com/ctrader-algo/references/Controls/ColorPicker/SelectedColorChanged/index.md)

## Inherited members

- `public void ResetProperty(ControlProperty property)` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/ResetProperty/index.md)
- `public Guid UniqueId {get;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/UniqueId/index.md)
- `public Style Style {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Style/index.md)
- `public double Left {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Left/index.md)
- `public double Top {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Top/index.md)
- `public double Right {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Right/index.md)
- `public double Bottom {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Bottom/index.md)
- `public double Width {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Width/index.md)
- `public double Height {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Height/index.md)
- `public double MinWidth {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/MinWidth/index.md)
- `public double MinHeight {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/MinHeight/index.md)
- `public double MaxWidth {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/MaxWidth/index.md)
- `public double MaxHeight {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/MaxHeight/index.md)
- `public bool IsEnabled {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/IsEnabled/index.md)
- `public bool IsVisible {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/IsVisible/index.md)
- `public double Opacity {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Opacity/index.md)
- `public Thickness Margin {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Margin/index.md)
- `public VerticalAlignment VerticalAlignment {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/VerticalAlignment/index.md)
- `public HorizontalAlignment HorizontalAlignment {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/HorizontalAlignment/index.md)
- `public Dock Dock {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/Dock/index.md)
- `public bool IsHitTestVisible {get; set;}` (from ControlBase) [details](https://help.ctrader.com/ctrader-algo/references/Controls/ControlBase/IsHitTestVisible/index.md)

