How to refresh Position in Combobox
02 Mar 2024, 02:42
i create Combobox for List All Position. but i cant refresh, how to realtime update i cant put it to OnTick()
private StackPanel CreateContentPanel(double RiskPerReward){
var contentPanel = new StackPanel { Margin = 10 }; var grid = new Grid(7, 10); grid.Columns[0].SetWidthInPixels(60); // Increase the width of the first column/ grid.Columns[1].SetWidthInPixels(55);//
OrderSelection = new ComboBox { Width = 50, Height = 20, HorizontalContentAlignment = HorizontalAlignment.Left, VerticalContentAlignment = VerticalAlignment.Bottom, }; List<Position> openPositions = new List<Position>(); foreach (var position in _robot.Positions) if (position.VolumeInUnits > 0) { // Add position label and PID to the ComboBox item //string itemText = $"({position.Id}){position.Label}"; string itemText = $"{position.Id}"; OrderSelection.AddItem(itemText); // Add position label and PID to the ComboBox _robot.RefreshData(); } // Subscribe to SelectedItemChanged event OrderSelection.FontSize = 12; OrderSelection.SelectedItemChanged += OrderSelection_SelectedItemChanged; grid.AddChild(OrderSelection, 2, 1); // Add myDropList at row 0, column 4 }

stepdominiz
02 Mar 2024, 13:51 ( Updated at: 03 Mar 2024, 07:09 )
i try this
openPositions.Clear();andopenPositions.Clear();still not work.List<Position> openPositions = new List<Position>();
openPositions.Clear();foreach (var position in _robot.Positions)
if (position.VolumeInUnits > 0)
{
// Add position label and PID to the ComboBox item
//string itemText = $"({position.Id}){position.Label}";
string itemText = $"{position.Id}";
OrderSelection.AddItem(itemText); // Add position label and PID to the ComboBox
}
@stepdominiz