Hi, just wanted to post this to give something back, at least to relative newcomers like myself.

Today I needed a drop down list, and wxComboBox looked like it would do. Unfortunately when looking up the help file, or with the code completion, nothing I tried would make the control act like I needed: populate it from empty, one item at a time, from inside a while loop.

In the routine that creates the controls, just above where the combo box is created, I found this line:
wxArrayString arrayStringFor_WxComboBox1;

Maybe I can manipulate the array directly... Nope, just got into more trouble. Here's the lesson I learned (in a post): if you are working with a derived class, look at what features are available for the parent. In this case, one of wxComboBox's parents is wxControlWithItems. Look in the help section for it, and there are all the features you couldn't find for wxComboBox.

wxString str;

For just outside your while loop:
WxComboBox1->Clear();

For adding entries from inside your loop:
WxComboBox1->Append(str);

Once outside your loop, the combo items will be out of sight below the first blank line. To fix this use:
WxComboBox1->SetSelection(0);

In my case I needed to convert some printf statements to strings for the combo box entries:
printf(" Product: %ls\n", cur_dev->product_string);

I ended up with this (more or less):
str.Printf(wxT(" Product: %ls"), cur_dev->product_string);
WxComboBox1->Append(str);

The wxT() around the text in quotes may not be necessary, not sure of that.

Hope this saves a new wxWidgets user some time.

Last edited by softport on Sat Dec 15, 2012 4:49 pm, edited 1 time in total.

I've been thinking about a really dumb analogy to working with derived classes...

Say you just built a pond in your back yard, and you would really like to have a duck swimming in it. You go and buy a duck, open the instructions, and all it tells you is how to make it quack. That's nice, but that's not why you got the duck. You keep trying to make it swim, but always end up all wet jumping in the pond to rescue it.

Finally one day you decide to go to the library, and find out all you can about ducks. You discover that ducks have a parent family called Anatidae. And there you find the instructions on how to make it swim! Great! You go home to try it, and sure enough you finally get the duck to swim, wondering why the original instructions didn't mention anything about it. Could there be something else it could do? It's got wings, so it should be able to fly, but there was no mention of this under 'Anatidae'. Now you know the drill, so you go back to the library, and discover that Anatidae have a parent family called birds. Soon you have your duck doing all sorts of tricks, and your neighbors aren't laughing at you anymore.