I have created this function in my DetailsScreen.cs, but i have no idea if this is the correct file to put this kind of code in, or if coding it this way is the correct approach. I know that it works because i have tested it. Please help me, i am only a student doing an internship and i can not get any proper help.
More details: My application generates a questionnare based on selected (cyber security) standards. I have a form DetailsScreen, which requires the user to fill in some details such as name, company, etc. They also need to select from a checkedlist (questionStandardInput), the question standard they wish to use in this interview. For each selected standard, two answer standards need to be selected from two drop down lists (maturity answer standard and compliance answers standard). Therefore, i need to be able to dynamically add labels and comboxes for each question standard. I asked because most code concerning label font etc. is placed in .Designer.cs files instead of the .cs files. But i need certain logic from the .cs file in order to properly format the controls, that's why i put it in here.
// Load answer input according to the number of questions standards selected.
private void questionStandardInput_MouseUp(object sender, MouseEventArgs e)
{
questionLabels.Clear();
maturityInput.Clear();
complianceInput.Clear();
selectionPanel.Controls.Clear();
foreach (var item in questionStandardInput.CheckedItems)
{
Label qs_label = new Label();
qs_label.Location = new Point(0, 0 + (questionLabels.Count * 115));
qs_label.Font = new Font("Arial", 12F, FontStyle.Regular);
qs_label.Size = new Size(150, 18);
qs_label.Text = item.ToString();
questionLabels.Add(qs_label);
this.selectionPanel.Controls.Add(qs_label);
Label m_label = new Label();
m_label.Location = new Point(0, 0 + (questionLabels.Count * 115 + 35));
m_label.Font = new Font("Arial", 12F, FontStyle.Regular);
m_label.Size = new Size(150, 18);
m_label.Text = "Maturity standard";
this.selectionPanel.Controls.Add(m_label);
Label c_label = new Label();
c_label.Location = new Point(0, 0 + (questionLabels.Count * 115 + 70));
c_label.Font = new Font("Arial", 12F, FontStyle.Regular);
c_label.Size = new Size(170, 18);
c_label.Text = "Compliance standard";
this.selectionPanel.Controls.Add(c_label);
ComboBox m_input = new ComboBox();
m_input.Location = new Point(170, 0 + (questionLabels.Count * 115 + 35));
m_input.Font = new Font("Arial", 12F, FontStyle.Regular);
m_input.Size = new Size(200, 22);
m_input.DropDownStyle = ComboBoxStyle.DropDownList;
maturityInput.Add(m_input);
this.selectionPanel.Controls.Add(m_input);
ComboBox c_input = new ComboBox();
c_input.Location = new Point(170, 0 + (questionLabels.Count * 115 + 70));
c_input.Font = new Font("Arial", 12F, FontStyle.Regular);
c_input.Size = new Size(200, 22);
c_input.DropDownStyle = ComboBoxStyle.DropDownList;
complianceInput.Add(c_input);
this.selectionPanel.Controls.Add(c_input);
InitializeMaturityStandardInput(m_input);
InitializeComplianceStandardInput(c_input);
}
this.saveAssessmentButton.Location = new Point(235, 0 + (questionLabels.Count * 115));
this.selectionPanel.Controls.Add(saveAssessmentButton);
}