c# - Using Generic Event Handler for Controls in Windows Forms! -
i have bunch of controls populated database when form loads. using dictionary (control.name key , control.value value) store inital values. when user changes values using other dictionary load current values , compare inital dictionary. if values different running kind of code prompt user of changes. think more hackish , looking better solution. please advise.
thanks
try this
for each ctrl control in me.controls if typeof ctrl checkbox addhandler (directcast(ctrl, checkbox).checkedchanged), addressof control_changed elseif typeof ctrl textbox addhandler (ctrl.textchanged), addressof control_changed elseif typeof ctrl numericupdown addhandler (directcast(ctrl, numericupdown).valuechanged), addressof control_changed end if next sub control_changed(byval sender object, byval e eventargs) ' handle events here end sub
Comments
Post a Comment