Guest User

Untitled

a guest
Aug 20th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace WindowsFormsApplication1
  5. {
  6. public partial class Form1 : Form
  7. {
  8. public int a, b, c;
  9.  
  10. public Form1()
  11. {
  12. InitializeComponent();
  13. }
  14.  
  15. private void JHandler(CheckBox checkBox, ref int value, TextBox textBox)
  16. {
  17. if (checkBox.Checked) {
  18. value += Convert.ToInt32(checkBox.Tag);
  19. } else {
  20. value -= Convert.ToInt32(checkBox.Tag);
  21. } textBox.Text = Convert.ToString(value);
  22. }
  23.  
  24. private void CheckBox_A_Click(object sender, EventArgs e)
  25. {
  26. JHandler((sender as CheckBox), ref a, textBox1);
  27. }
  28.  
  29. private void CheckBox_B_Click(object sender, EventArgs e)
  30. {
  31. JHandler((sender as CheckBox), ref b, textBox2);
  32. }
  33.  
  34. private void CheckBox_C_Click(object sender, EventArgs e)
  35. {
  36. JHandler((sender as CheckBox), ref c, textBox3);
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment