Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The code below works: however, I'm still interested in hearing if there is a better way to do this?</p> <pre><code> private void CheckBox_CheckedChanged(System.Object sender, System.EventArgs e) { if (((CheckBox)sender).Checked) { switch (((CheckBox)sender).Name) { case "CheckBox1": sb.Append("This is checkbox 1.\r\n"); break; case "CheckBox2": sb.Append("This is checkbox 2.\r\n"); break; case "CheckBox3": sb.Append("This is checkbox 3.\r\n"); break; case "CheckBox4": sb.Append("This is checkbox 4.\r\n"); break; case "CheckBox5": sb.Append("This is checkbox 5.\r\n"); break; case "CheckBox6": sb.Append("This is checkbox 6.\r\n"); break; case "CheckBox7": sb.Append("This is checkbox 7.\r\n"); break; case "CheckBox8": sb.Append("This is checkbox 8.\r\n"); break; case "CheckBox9": sb.Append("This is checkbox 9.\r\n"); break; case "CheckBox10": sb.Append("This is checkbox 10.\r\n"); break; } txtBox.Text = sb.ToString(); } else { switch (((CheckBox)sender).Name) { case "CheckBox1": sb.Replace("This is checkbox 1.\r\n", ""); break; case "CheckBox2": sb.Replace("This is checkbox 2.\r\n", ""); break; case "CheckBox3": sb.Replace("This is checkbox 3.\r\n", ""); break; case "CheckBox4": sb.Replace("This is checkbox 4.\r\n", ""); break; case "CheckBox5": sb.Replace("This is checkbox 5.\r\n", ""); break; case "CheckBox6": sb.Replace("This is checkbox 6.\r\n", ""); break; case "CheckBox7": sb.Replace("This is checkbox 7.\r\n", ""); break; case "CheckBox8": sb.Replace("This is checkbox 8.\r\n", ""); break; case "CheckBox9": sb.Replace("This is checkbox 9.\r\n", ""); break; case "CheckBox10": sb.Replace("This is checkbox 10.\r\n", ""); break; } txtBox.Text = sb.ToString(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload