c# - Adding event handlers Dynamically to controls within a panel -
i've class in nutshell:
class mypanel { panel p_panel; //declaring elements need checkbox cb_choice; radiobutton rb_nagy, rb_kicsi; textbox tb_db; public panel getpanel() { create(); //creating elements need, putting them in created panel. customize(); //setting panel's size, , other control's locations within panel. return p_panel; //so if call method other class, method return panel controls inside.
in other class, i've list of panels of have been created above method. layout done, , works neatly, can add many want screen. want add function these controls. example, want radiobuttons disabled unless checkbox enabled. how can add check changed event checkboxes in list of panels?
it seems want know how dynamically add eventhandler
s controls!?
it can done this:
cb_choice.checkedchanged += cb_choice_checkedchanged;
or if want more explicit (both ways work same).
cb_choice.checkedchanged += new eventhandler(cb_choice_checkedchanged);
and define handler method:
private void cb_choice_checkedchanged(object o, eventargs args) { //add code enable/disable radiobuttons }
Comments
Post a Comment