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 eventhandlers 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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -