How to cast a ListBox item to an int for a switch statment?
I'm at a loss here. I'm trying to run a function with certain
parameters according to which item the user selects in a listbox.
I've tried all kinds of different casting methods to try to change
the item of the listbox into an int or a char so I could use it in a
switch statement but C++.NET 2k3 doesn't like whatever I try.
I'm pretty sure that the item coming from the listbox is a
managed Object*. Am I right?
I've tried some things like this:
As far as I know, there's no ->ToInt() method.
__box(char*) c = reinterpret_cast<__box(char*)>(listboxRadStr->SelectedItem->ToString());
int* i = dynamic_cast<int*>(listboxRadStr->SelectedItem);
Also, if you want to fill a listbox with items (a collection?) and
you started your project as an empty managed C++ project,
what's the best way to fill the listbox with items? I just want to
put numbers 1 - 12 in the listbox, unordered (so i don't get 1,
10, 11, 12, 2, 3...). I'd like to center the items in the listbox
Thanks a bunch for any help you can provide.