Some who may remember a couple of posts from me ages ago will know I am a complete part-time noob (!)
I am getting somewhere with my 'game'. Now I am just kind of cleaning things up and other bits to take my mind off the main program workings for a little bit (my head hurts...)
Right now, I have four combo boxes on my form and the items in the collection are built in another section of code (specifically, the end turn button) which you can see below:
Now the fun part is fiddling with these collections each time a user changes the selection in one combo box. Something like, in the first box, the user selects 13 from a selection of 13 to 18. The other boxes are now modified to remove 13 from their collections like so:Code:for(int loop = 0 ; loop <= 3 ; loop++) { ((ComboBox)ActionNameComboBoxes[loop]).Items.Clear(); } if(tech[0,24] > 0 && tech[0,13] > 0) { for(int sohg = 0; sohg <= tech[0,24]-1; sohg++) { ((ComboBox)ActionNameComboBoxes[sohg]).Enabled = true; for(int sohg2 = 13; sohg2 <= tech[0,13]+12; sohg2++) { ((ComboBox)ordercomboboxes[sohg]).Items.Add(sohg2.ToString()); } } }
I am wanting to deal with a user that is spelt with an L at the beginning. Ie, the user selects 13, 14, 15, 16 respectively in each box, but then decides to change his 13 selection to 17. I am struggling on adding 13 back in to each combobox selection! What is the best way of doing this? No need to do it for me, just give a way of doing it, that I can work on.Code:public void OLActionBox_SelectedIndexChanged(object sender, System.EventArgs e) { for(int sohg2 = 13; sohg2 <= tech[0,24]+12; sohg2++) { if(((System.Windows.Forms.ComboBox)sender).Name != ((ComboBox)ordercomboboxes[sohg2-13]).Name) { ((ComboBox)ordercomboboxes[sohg2-13]).Items.Remove((string)((System.Windows.Forms.ComboBox)sender).SelectedItem); } } }
And now for the random numbers. I hate random numbers. How can I generate in a loop 12 different numbers, but all in the range of 0 to 11?
Thats what I can figure out, except the program hangs in this loop.Code:for( loop = 0 ; loop <= 11 ; loop++) { array[loop] = rnd.Next(0,11) }



LinkBack URL
About LinkBacks


