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

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

# ComboBox (class)

A control that shows drop down list of items and allows user to select a single item from the list

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 ComboBox : Control
```

## Examples

C#:

```csharp
using cAlgo.API;

namespace cAlgo;

public partial class Test : Indicator
{
    protected override void Initialize()
    {
        var comboBox = new ComboBox
        {
            HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment = VerticalAlignment.Center,
            Width = 100
        };

        for (var i = 0; i < 10; i++)
            comboBox.AddItem($"Item {i}");

        comboBox.SelectedIndex = 0;
        comboBox.SelectedItemChanged += args => Print($"ComboBox selected item changed to: {args.SelectedItem}");

        Chart.AddControl(comboBox);
    }

    public override void Calculate(int index)
    {
    }
}
```

Python:

```python
import clr
clr.AddReference("cAlgo.API")

from cAlgo.API import *

class Test():
    def initialize(self):
        comboBox = ComboBox()
        comboBox.HorizontalAlignment = HorizontalAlignment.Center
        comboBox.VerticalAlignment = VerticalAlignment.Center
        comboBox.Width = 100

        for i in range(10):
            comboBox.AddItem(f"Item {i}")

        comboBox.SelectedIndex = 0
        comboBox.SelectedItemChanged += lambda args: api.Print(f"ComboBox selected item changed to: {args.SelectedItem}")

        api.Chart.AddControl(comboBox)
```

config.json:

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

## Constructors

- `public ComboBox()` — Creates a new empty ComboBox with default ComboBox Style [details](https://help.ctrader.com/ctrader-algo/references/Controls/ComboBox/Constructor/index.md)

## Methods

- `public void AddItem(string item)` — Adds a new item to the ComboBox [details](https://help.ctrader.com/ctrader-algo/references/Controls/ComboBox/AddItem/index.md)
- `public void RemoveItem(string item)` — Removes an existing item from the ComboBox [details](https://help.ctrader.com/ctrader-algo/references/Controls/ComboBox/RemoveItem/index.md)

## Properties

- `public int SelectedIndex {get; set;}` — Set / Get the ComboBox selected item index [details](https://help.ctrader.com/ctrader-algo/references/Controls/ComboBox/SelectedIndex/index.md)
- `public string SelectedItem {get; set;}` — Set / Get the ComboBox selected item [details](https://help.ctrader.com/ctrader-algo/references/Controls/ComboBox/SelectedItem/index.md)

## Events

- `public event Action<ComboBoxSelectedItemChangedEventArgs> SelectedItemChanged;` — This event will trigger if the ComboBox selected item changed [details](https://help.ctrader.com/ctrader-algo/references/Controls/ComboBox/SelectedItemChanged/index.md)

## Inherited members

- `public Color ForegroundColor {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/ForegroundColor/index.md)
- `public Color BackgroundColor {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/BackgroundColor/index.md)
- `public Thickness Padding {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/Padding/index.md)
- `public VerticalAlignment VerticalContentAlignment {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/VerticalContentAlignment/index.md)
- `public HorizontalAlignment HorizontalContentAlignment {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/HorizontalContentAlignment/index.md)
- `public FontWeight FontWeight {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/FontWeight/index.md)
- `public FontStyle FontStyle {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/FontStyle/index.md)
- `public string FontFamily {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/FontFamily/index.md)
- `public double FontSize {get; set;}` (from Control) [details](https://help.ctrader.com/ctrader-algo/references/Controls/Control/FontSize/index.md)
- `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)

