nak4:Is it possible to remove items from a Combobox? I know that CComboBox.AddItem() can be used to add items to Combobox but I cannot figure out how to remove items from Combobox.
CComboBox has the following virtual methods. So use the ItemDelete one.
virtual bool ItemAdd(const string item,const long value=0) { return(m_list.ItemAdd(item,value)); } virtual bool ItemInsert(const int index,const string item,const long value=0) { return(m_list.ItemInsert(index,item,value)); } virtual bool ItemUpdate(const int index,const string item,const long value=0) { return(m_list.ItemUpdate(index,item,value)); } virtual bool ItemDelete(const int index) { return(m_list.ItemDelete(index)); } virtual bool ItemsClear(void) { return(m_list.ItemsClear()); }
When in doubt, look at the source code for the Standard Library ... "MQL5\Include\Controls\ComboBox.mqh"
nak4 #:I couldn't find those virtual methods.It worked as I expected. Thank you so much.
You are welcome! Virtual methods are not described in the documentation unfortunately. You can only find out about them by looking at the source code. That is why I stated "When in doubt, look at the source code".
Fernando Carreiro #:
You are welcome! Virtual methods are not described in the documentation unfortunately. You can only find out about them by looking at the source code. That is why I stated "When in doubt, look at the source code".
You are welcome! Virtual methods are not described in the documentation unfortunately. You can only find out about them by looking at the source code. That is why I stated "When in doubt, look at the source code".
I have another related question. How to remove the current selected item in the combobox?
ItemDelete takes in index, but how to get index of current selected item?
Seems like the only way is to check the index via m_list, but this is protected variable.
I have to work around via the following codes:
class myCComboBox:public CComboBox { public: void CurrentItemDelete() { ItemDelete(m_list.Current()); } };
Am I missing something?

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello!
Is it possible to remove items from a Combobox?
I know that CComboBox.AddItem() can be used to add items to Combobox but I cannot figure out how to remove items from Combobox.
Thanks for taking your time.