I have a combo box (MFC) that have 3 data entries in it.
Lets say they are...
data1
data2
data3
How do I make it so that when i press a button, the data randomize and display? Please help.
I have a combo box (MFC) that have 3 data entries in it.
Lets say they are...
data1
data2
data3
How do I make it so that when i press a button, the data randomize and display? Please help.
First make sure the Sort property of the ComboBox is turned off.
And the rest.... there must be a simpler way to do this but I'll give it a try:
Code:int nofItems = 0; int len = 0; // item length int randIndex = 0; // index to item (random) char item[1024]; nofItems = Box.GetCount(); srand(time(NULL)); for(int i = 0; i < nofItems; i++) { randIndex = rand() % nofItems; // pick random item len = Box.GetLBTextLen(randIndex); // get length of string Box.GetLBText(randIndex, item); // save string Box.DeleteString(randIndex); // delete string from list Box.AddString(item); // add string at end of list }
Thank you for replying, but I'm still unclear about this. I assumed that "Box" is my combobox, but my combobox control name is IDC_COMBOTEST, how do I tell the name of my box?
In VC++ 6.0:
Open ClassWizzard: View -> ClassWizzard (or CTRL+W)
Select tab "Member Variables"
Select your control ID (IDC_COMBOTEST)
Press button "Add variable..."
Enter the name of the member variable (m_DialogBox)
Category: Control (not String)
Variable type: CComboBox
Press "OK"
Now you have added a new variable called m_DialoxBox.
You can use this variable to update the Dialog Box.