Checked Changed Event
this is the default event of both the above 2 controls which occurs when the controls are selected as well as de-selected also. To work with the event design a form as following
Class Declarations
int count = 0;
Code under CheckedChanged Event Procedure of all CheckBox’s
radioButton1.Checked = true; int amt = int.Parse(txtFees.Text); CheckBox cb = sender as CheckBox; if (cb.Checked) { count += 1; amt += Convert.ToInt32(cb.Tag); } else { count -= 1; amt -= Convert.ToInt32(cb.Tag); } txtFees.Text = amt.ToString();
Code under CheckedChanged Event Procedure of all RadioButton’s:
int amt = int.Parse(txtFees.Text); RadioButton rb = sender as RadioButton; if (rb.Checked) amt += (Convert.ToInt32(rb.Tag) * count); else amt -= (Convert.ToInt32(rb.Tag) * count); txtFees.Text = amt.ToString();
Code under Click Event Procedure of Reset Form Button
foreach (Control ctrl in groupBox1.Controls) { CheckBox cb = ctrl as CheckBox; cb.Checked = false; } foreach (Control ctrl in this.Controls) { if (ctrl.GetType().Name == "TextBox"){ TextBox tb = ctrl as TextBox; tb.Clear(); } } txtFees.Text = "0"; txtName.Focus();
Code under Click Event Procedure of Reset Form Button:
this.Close();