Hi,
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, and if the code is even 'correct'. 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.
Greetings,
Marthe
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, and if the code is even 'correct'. 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.
C#:
private void questionStandardInput_MouseUp(object sender, MouseEventArgs e)
{
questionLabels.Clear();
maturityInput.Clear();
complianceInput.Clear();
selectionPanel.Controls.Clear();
foreach (var item in questionStandardInput.CheckedItems)
{
Label m_label = new Label();
m_label.Location = new Point(0, 0 + (questionLabels.Count * 115 + 35));
m_label.Name = item.ToString() + "MLabel";
m_label.Font = new Font("Arial", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
m_label.Size = new System.Drawing.Size(150, 18);
m_label.Text = "Maturity standard";
this.selectionPanel.Controls.Add(m_label);
ComboBox m_input = new ComboBox();
m_input.Location = new Point(170, 0 + (questionLabels.Count * 115 + 35));
m_input.Name = item.ToString() + "MLabel";
m_input.Font = new Font("Arial", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
m_input.Size = new System.Drawing.Size(200, 22);
m_input.DropDownStyle = ComboBoxStyle.DropDownList;
maturityInput.Add(m_input);
this.selectionPanel.Controls.Add(m_input);
Label c_label = new Label();
c_label.Location = new Point(0, 0 + (questionLabels.Count * 115 + 70));
c_label.Name = item.ToString() + "CLabel";
c_label.Font = new Font("Arial", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
c_label.Size = new System.Drawing.Size(170, 18);
c_label.Text = "Compliance standard";
this.selectionPanel.Controls.Add(c_label);
ComboBox c_input = new ComboBox();
c_input.Location = new Point(170, 0 + (questionLabels.Count * 115 + 70));
c_input.Name = item.ToString() + "MLabel";
c_input.Font = new Font("Arial", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
c_input.Size = new System.Drawing.Size(200, 22);
c_input.DropDownStyle = ComboBoxStyle.DropDownList;
complianceInput.Add(c_input);
this.selectionPanel.Controls.Add(c_input);
Label qs_label = new Label();
qs_label.Location = new Point(0, 0 + (questionLabels.Count * 115));
qs_label.Name = item.ToString() + "QSLabel";
qs_label.Font = new Font("Arial", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
qs_label.Size = new System.Drawing.Size(150, 18);
qs_label.Text = item.ToString();
questionLabels.Add(qs_label);
this.selectionPanel.Controls.Add(qs_label);
InitializeMaturityStandardInput(m_input);
InitializeComplianceStandardInput(c_input);
}
this.saveAssessmentButton.Location = new Point(235, 0 + (questionLabels.Count * 115));
this.selectionPanel.Controls.Add(saveAssessmentButton);
}
Greetings,
Marthe
Last edited: