c# - Dynamic button event not working -
i developing winforms program requires me dynamically add buttons program. i've created many buttons , other controls particular button's event not working.
here have done.
create controls class
public createcontrol(form form) { this.form = form; } public button button1; public void addbutton() { button1 = new button(); this.button1.location = new system.drawing.point(387, 665); this.button1.name = "button1"; this.button1.size = new system.drawing.size(75, 23); this.button1.tabindex = 0; this.button1.text = "view"; this.button1.usevisualstylebackcolor = true; form.controls.add(this.button1); }
form class
// cc defined in constructor object of createcontrol private void loadselectpatientcontrols() { cc.addbutton(); cc.button1.click += new system.eventhandler(this.button1_click); } private void button1_click(object sender, eventargs e) { showlist(); }
i had breakpoint on button1_click
, never fired whereas other controls (including buttons) able trigger respective events. there might of missed out on?
Comments
Post a Comment