I've a three layer architecture. On the top layer is my GUI and on the second layer are my Business classes. On the GUI are many checkboxes (+20 items) and a "Start"-button available. If the User click on the button I would like to handover the status of the checkboxes to a business object via constructor.
To pass a List<Checkbox>
is not a suitable way and the solution should be flexible for changes. Additionally I need a possibility to identify the checkbox status on the business-layer. Is there a common possibility to solve this?
Here a example to my question:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
for (int i = 0; i < 20; i++)
{
flowLayoutPanel1.Controls.Add(CreateCheckbox(i));
}
var button = new Button();
button.Name = "StartButton";
button.Text = "Start";
button.Click += new EventHandler(button_Click);
flowLayoutPanel1.Controls.Add(button);
}
private void button_Click(object sender, EventArgs e)
{
var businessObject
= new BusinessClass(/*How to handover the checkbox status*/);
}
private CheckBox CreateCheckbox(int index)
{
var checkBox = new CheckBox();
checkBox.Name = "checkBox" + index;
checkBox.Text = "checkBox" + index;
return checkBox;
}
}