Just create an array of CheckBoxes Then use the loop...
Code:if(CheckBox[i].IsChecked) //Do yourz stuffz here :P
Is it possible to do some looping that checks multiple checkboxes after eachother
like:
?Code:for(int B = 1 , 18 , B--) { if(checkboxB = true) { writeInteger(0xadress + 0x((B-1)*OFFSET); } }
Last edited by stevonator; 08-09-2012 at 12:54 PM.
Just create an array of CheckBoxes Then use the loop...
Code:if(CheckBox[i].IsChecked) //Do yourz stuffz here :P
CoD Minion from 09/19/2012 to 01/10/2013
stevonator (08-09-2012)
So instead of the B it's [i] , ok thx, i'll try it when i have time
I just need this because if i didn't use it i should hardcode 152 checkboxes xD long live loops
Like this:
Here is my Tip:Code:void Loop_CheckBoxses() { foreach (Control C in this.Controls)//Loops over all the controls in the Form1 (this = The Form) { if (C is CheckBox)//Checks if the C (Control) is an CheckBox { CheckBox CheckBoxC = C as CheckBox; //We "create" a checkbox of the Control C (We do this to have the funtions of the CheckBox) if (CheckBoxC.Checked) //Checks if the Checbox is checked { //Do your actions here } } } }
Code:void Loop_CheckBoxses() { int Loops = 0; foreach (Control C in this.Controls) { if (C is CheckBox) { CheckBox CheckBoxC = C as CheckBox; if (CheckBoxC.Checked) { Loop_SubHack(Loops); } Loops++; } } } void Loop_SubHack(int Loop) { //Switch/Case Statement //This is recommended if you want an easy view over your codes. //NOTE: You need to write 1 line extra tho.. (break;) instead of the IFs switch (Loop) { case 0: MessageBox.Show("Write your Integer here", "0"); break; case 1: MessageBox.Show("Write your Integer here", "1"); break; } //OR use the IF statement... //Easy usage, but not that good over-view if(Loop == 0) MessageBox.Show("Write your Integer here", "0"); if(Loop == 1) MessageBox.Show("Write your Integer here", "1"); }
Last edited by Jorndel; 08-10-2012 at 05:36 AM.
so in my case, does this code makes sense...? (Loops is the number of checkboxes it's currently at..?)
Code:void Loop_CheckBoxses() { int Loops = 0; foreach (Control C in this.Controls) { if (C is CheckBox) { CheckBox CheckBoxC = C as CheckBox; if (CheckBoxC.Checked) { Loop_SubHack(Loops); } Loops++; } } } void Loop_SubHack(int Loop) { if(Loop >= 0 & Loop <= 17) writeInteger(0x address + (0x (int.parse(Loop)*OFFSET)), value) if(Loop >= 18 & Loop <= 35) writeInteger(0x address + (0x (int.parse(Loop)*OFFSET)), value) ...etc etc etc }
Indeed
Or you can just short your code even more
Code:void Loop_CheckBoxses() { int Loops = 0; foreach (Control C in this.Controls) { if (C is CheckBox) { CheckBox CheckBoxC = C as CheckBox; if (CheckBoxC.Checked) { if(Loop >= 0 & Loop <= 17) { writeInteger(0x address + (0x (int.parse(Loop)*OFFSET)), value) } if(Loop >= 18 & Loop <= 35) { writeInteger(0x address + (0x (int.parse(Loop)*OFFSET)), value) } } Loops++; } } }
ok i see, thanks a lot, i'll try it tommorow (cause now i can't go on my laptop :/ ) but thanks, credits for code help go to several people, like you
EDIT: so if all goes well, this should only write to the byte when the checkbox is checked and when the loopnumber is correct...
and the checkboxes check in order... so it begins with checkbox1,2,3,4,...
Last edited by stevonator; 08-10-2012 at 10:32 AM.
Maybe :S
You just have to try :P
Else just check the name (Unless you changed the names...)
And check if it contains like: Checkbox1 (1)
And then see if it's within the Range
If you need some help in that:
(Code free hand)
string NumCheck = CheckBoxC.Name.Replace("CheckBox", "");
Code:void Loop_CheckBoxses() { foreach (Control C in this.Controls) { if (C is CheckBox) { CheckBox CheckBoxC = C as CheckBox; if (CheckBoxC.Checked) { int NumCheck = int.Parse(CheckBoxC.Name.Replace("CheckBox", "")); if(NumCheck >= 0 & NumCheck <= 17) { writeInteger(0x address + (0x (int.parse(NumCheck)*OFFSET)), value) } if(NumCheck >= 18 & NumCheck <= 35) { writeInteger(0x address + (0x (int.parse(NumCheck)*OFFSET)), value) } } } } }
Means I just removed the name of the checkbox (default name)
and is left with only the number value.
And then I compare that with the check you have
ok thx
i actually made a mistake, for the 2nd if statement i have to do the int.parse minus 18 (18 players, so the first checkbox would start again with player 1 instead of with player 19)
Jorndel (08-10-2012)
sorry for double post
this code doesn't do anything, i check 1 checkbox (1st one) and this code:
and it doesn't do anything when any of those checkboxes is checked and i click the buttonCode:private void button2_Click(object sender, EventArgs e) { int Loops = 0; foreach (Control C in this.Controls) { if (C is CheckBox) { CheckBox CheckBoxC = C as CheckBox; if (CheckBoxC.Checked) { if(Loops >= 0 & Loops <= 17) { MessageBox.Show("between 0 and 17"); } if(Loops >= 18 & Loops <= 35) { MessageBox.Show("between 18 and 35"); } } Loops++; } }
Last edited by stevonator; 08-11-2012 at 04:43 AM.