0
I have a list that returns from the database and for each record I need to create a checkbox
of dynamic form, I did a search and found some examples for Webforms and I need an example for Windows Forms
It would be something like this, Example:
private void CriarCheckboxDinamicamente()
{
try
{
for (int i = 0; i < 3; i++)
{
this.SuspendLayout();
var chk = new System.Windows.Forms.CheckBox();
chk.Name = "Motivo" + i.ToString();
chk.Text = "Motivo" + i.ToString();
pnlModalMotivo.Controls.Add(chk);
this.ResumeLayout(false);
}
}
catch(Exception ex)
{
MessageBox.Show("Erro: " + ex.Message);
}
}
You could also use a Flowlayoutpanel for example
– Henrique