Im trying to Double Click
on a Label
in a FlowLayoutPanel
, The labels are created dynamically.
Im trying to open the form using this
foreach(Label label in myFlp )
{
var Id = label.Name.ToString();
int personID;
if (!String.IsNullOrWhiteSpace(Id) && int.TryParse(Id, out personID))
{
FrmAddress frmAddress = new FrmAddress(_controller, personID);
frmAddress.ShowDialog();
frmAddress.Dispose();
}
}
Getting this error;
foreach statement cannot operate on variables of type 'System.Windows.Forms.FlowLayoutPanel' because 'System.Windows.Forms.FlowLayoutPanel' does not contain a public definition for 'GetEnumerator'
Try something like this :
foreach(var control in myFLp.Controls)
{
if(control is Label)
var Id = (Label)control.Name.ToString();
int personID;
if (!String.IsNullOrWhiteSpace(Id) && int.TryParse(Id, out personID))
{
FrmAddress frmAddress = new FrmAddress(_controller, personID);
frmAddress.ShowDialog();
frmAddress.Dispose();
}
}