Briefly, my app adds checkboxes programmatically into a flowlayoutpanel named "fp".
fp.Controls.Add(new CheckBox() { Name = "cb1", Text = "New Checkbox", Checked = true, AutoSize = true, AllowDrop = true });
i'm stuck trying to add a mouseclick event inside that new Checkbox instance. I tried adding the line below into the code above.
this.MouseDown += new MouseEventHandler(cbox_MouseDown);
But I get Invalid initializer member declarator
I also tried to add this:
((CheckBox)(this.Controls.Find("cb1", false))[0]).MouseDown += new MouseEventHandler(cbox_MouseDown);
before adding the new checkbox instance but it does not work either.
I could highly appreciate a way to insert the event directly into the new CheckBox() instance .
Thank you guys <3