My project is now handling more check boxes which means passing more checkbox status to the "Test Results Form", currently there are 4 check boxes of which I send the status for whether the checkbox is checked or not like this:
TestResults testResultsForm = new TestResults
(logonServiceBool,createCustomerBool,createAgreementBool,postBalanceAdjBool);
createCustomerBool = createCustomerCheckBox.Checked;
I now have 60 Check boxes on the form and so I thought about managing them in an array so I created arrays for all the check boxes like this (This is one of three of the arrays I have, they all sets of check boxes for tests I will be running on the Test results Form depending on if its been checked or not):
//Checkbox Arrays...
CheckBox[] drop1CheckBoxes = new CheckBox[5];
//Drop 1 Checkbox into array...
drop1CheckBoxes[0] = createCustomerCheckBox;
drop1CheckBoxes[1] = createAgreementCheckBox;
drop1CheckBoxes[2] = updateAgreementAdditionalDetailsCheckBox;
drop1CheckBoxes[3] = updateCustomerAdditionalDetailsCheckBox;
drop1CheckBoxes[4] = addContactDetailsCheckBox;
On the Test Results Form I receive the passed variables like this:
public TestResults
(
CheckBox[] drop1CheckBox,
string username,
string password,
bool logonServiceBool,
bool createCustomerServiceBool,
bool createAgreementServiceBool,
bool postBalanceAdjServiceBool
)
{
InitializeComponent();
inputtedUsername = username;
inputtedPassword = password;
logonAPITestChecked = logonServiceBool;
createCustomerAPITestChecked = createCustomerServiceBool;
createAgreementAPITestChecked = createAgreementServiceBool;
postBalanceAdjAPITestChecked = postBalanceAdjServiceBool;
drop1CheckBoxStatus = drop1CheckBox;
}
So I am trying to pass the whole array of the checkbox which works but then when in code trying to access the array to see the status of the checkbox when I type:
drop1CheckBoxStatus[0].
It says cannot apply indexing[] to type array. I have tried Array in stead of CheckBox but same problem appears.
Whats the easiest way to get around passing these array of check boxes to access their status of whether they are checked or not.
I want to avoid doing this:
(logonServiceBool,createCustomerBool,createAgreementBool,postBalanceAdjBool);
for all 60 of my check boxes.
Aucun commentaire:
Enregistrer un commentaire