---
id: "M:cAlgo.API.Style.Set(cAlgo.API.ControlProperty,System.Object,cAlgo.API.ControlState)"
kind: "method"
type: "T:cAlgo.API.Style"
url: "https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/Set/"
---

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

# Style.Set

Member of [Style](https://help.ctrader.com/ctrader-algo/references/Controls/Styles/Style/index.md).

## Set(ControlProperty property, object value, ControlState state)

Provides data for the chart control Style for the specified ControlProperty and the ControlState.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public void Set(ControlProperty property, object value, ControlState state)
```

Python:

```python
style.Set(property: ControlProperty, value: object, state: ControlState) -> None
```

### Parameters

- `property` (`ControlProperty`, Python `ControlProperty`): The control property
- `value` (`object`, Python `object`): The property value
- `state` (`ControlState`, Python `ControlState`): Control state

### Examples

C#:

```csharp
var style = new Style();
style.Set(ControlProperty.BackgroundColor, Color.DarkGreen, ControlState.DarkTheme);
style.Set(ControlProperty.BackgroundColor, Color.LightGreen, ControlState.LightTheme);
style.Set(ControlProperty.BackgroundColor, Color.Gray, ControlState.Disabled);
Chart.AddControl(new Button { Text = "Buy", Style = style });
```

Python:

```python
style = Style()
style.Set(ControlProperty.BackgroundColor, Color.DarkGreen, ControlState.DarkTheme)
style.Set(ControlProperty.BackgroundColor, Color.LightGreen, ControlState.LightTheme)
style.Set(ControlProperty.BackgroundColor, Color.Gray, ControlState.Disabled)
button = Button()
button.Text = "Buy"
button.Style = style
api.Chart.AddControl(button)
```

## Set(ControlProperty property, object value)

Sets the chart control Style for the specified ControlProperty.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
public void Set(ControlProperty property, object value)
```

Python:

```python
style.Set(property: ControlProperty, value: object) -> None
```

### Parameters

- `property` (`ControlProperty`, Python `ControlProperty`): The control property
- `value` (`object`, Python `object`): The property value

### Examples

C#:

```csharp
var style = new Style();
style.Set(ControlProperty.ForegroundColor, Color.Gold);
style.Set(ControlProperty.FontWeight, FontWeight.Bold);
Chart.AddControl(new TextBlock { Text = "Daily target reached", Style = style });
```

Python:

```python
style = Style()
style.Set(ControlProperty.ForegroundColor, Color.Gold)
style.Set(ControlProperty.FontWeight, FontWeight.Bold)
textBlock = TextBlock()
textBlock.Text = "Daily target reached"
textBlock.Style = style
api.Chart.AddControl(textBlock)
```

