Dynamically adding an event handler to checkbox
I have created a treeview from xml file by calling addTreenode. In my treeview each treeViewItem has a checkbox created dynamically.I want to call an event when one of the checkbox is checked... How to add an event handler to this checkbox's... Thanks in advance
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Aug 29, 2012, 9:58 PM EDT
CheckBox chk = \\get checkbox control if (chk != null) { chk.CheckedChanged += new EventHandler(chk_CheckedChanged); } then protected void chk_CheckedChanged(object sender, EventArgs e) { //dosomething }Pankaj Singh2 reputationPosted Oct 13, 2014, 9:17 AM EDT
CheckBox.Click += new RoutedEventHandler(CheckBox_Checked);
this will make CheckBox to call the handler function on each click... Tested..