Wx 3.1.1, Windows 10, I have a wxComboBox that I instantiate with
m_comboBoxFilename = new wxComboBox(this, wxID_ANY, wxT("Settings"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0);
It works fine and I can populate the list with wxComboBox::Append(..) and set the displayed value with wxComboBox::SetValue(..). I need to occasionally clear the list and append new list values, which is where I run into trouble. When I clear the list with wxComboBox::Clear(..), ::SetValue(..) no longer sticks. It displays when I step thru the code setting its value:
but when return control to Wx, it disappears:
And I'm left with a flashing cursor in the text window. I can type value:
But this isn't the behaviour I need. I only support list values, not custom entered value.
I'm sure I doing something ridiculous. Any advice is appreciated.
wxComboBox::Clear() preventing selection from sticking?
-
- Experienced Solver
- Posts: 58
- Joined: Mon Jul 03, 2017 12:03 am
Re: wxComboBox::Clear() preventing selection from sticking?
Hard to tell without seeing code or a running sample. My best guess is that after clearing and refilling the list, some code gets called that should not get called. Maybe because of a skipped event that should not get skipped? Just a wild guess.
Use the source, Luke!
-
- Experienced Solver
- Posts: 58
- Joined: Mon Jul 03, 2017 12:03 am
Re: wxComboBox::Clear() preventing selection from sticking?
doublemax, thanks for the thoughts. It wouldn't surprise me if I'm calling something wrong as you say but am really just using the functions I mentioned in my OP, though maybe not in order?
I did find a workaround that suits my needs. Rather than using ::SetValue(..) to update the combobox, I find the index of the value I want to set in my list and then use ::SetSelection(..). Works great now.
I did find a workaround that suits my needs. Rather than using ::SetValue(..) to update the combobox, I find the index of the value I want to set in my list and then use ::SetSelection(..). Works great now.