Skip to content

ComboBox.SelectedItem

property · ComboBox · cAlgo.API

DesktopCLICloud

Set / Get the ComboBox selected item

Environment behaviour

CLI — not supported. Accepted without error but never displayed, so control events such as Click are never raised.

Cloud — not supported. Accepted without error but never displayed, so control events such as Click are never raised.

Definition

public string SelectedItem {get; set;}
comboBox.SelectedItem: str

Returns string

Examples

var comboBox = new ComboBox();
comboBox.AddItem("Buy");
comboBox.AddItem("Sell");
comboBox.SelectedItem = "Sell";
Chart.AddControl(comboBox);
var tradeType = comboBox.SelectedItem == "Buy" ? TradeType.Buy : TradeType.Sell;
Print("Selected trade type: {0}", tradeType);
comboBox = ComboBox()
comboBox.AddItem("Buy")
comboBox.AddItem("Sell")
comboBox.SelectedItem = "Sell"
api.Chart.AddControl(comboBox)
tradeType = TradeType.Buy if comboBox.SelectedItem == "Buy" else TradeType.Sell
api.Print(f"Selected trade type: {tradeType}")