Skip to content

ComboBox

Summary

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

Signature

1
public class ComboBox : Control

Namespace

cAlgo.API

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 using cAlgo.API;
 namespace cAlgo;
 [Indicator(AccessRights = AccessRights.None)]
 public 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)
     {
     }
 }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 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: print(f"ComboBox selected item changed to: {args.SelectedItem}")
         api.Chart.AddControl(comboBox)

Methods

AddItem

Summary

Adds a new item to the ComboBox

Signature

1
public void AddItem(string item)

Parameters

Name Type Description
item string The string value that will be added on ComboBox

Return Value

void

RemoveItem

Summary

Removes an existing item from the ComboBox

Signature

1
public void RemoveItem(string item)

Parameters

Name Type Description
item string The string value that will be removed from ComboBox

Return Value

void

Properties

SelectedItem

Summary

Set / Get the ComboBox selected item

Signature

1
public string SelectedItem {get; set;}

Return Value

string

SelectedIndex

Summary

Set / Get the ComboBox selected item index

Signature

1
public int SelectedIndex {get; set;}

Return Value

int

Events

SelectedItemChanged

Summary

This event will trigger if the ComboBox selected item changed

Signature

1
public event Action<ComboBoxSelectedItemChangedEventArgs> SelectedItemChanged;