Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public int a, b, c;
- public Form1()
- {
- InitializeComponent();
- }
- private void JHandler(CheckBox checkBox, ref int value, TextBox textBox)
- {
- if (checkBox.Checked) {
- value += Convert.ToInt32(checkBox.Tag);
- } else {
- value -= Convert.ToInt32(checkBox.Tag);
- } textBox.Text = Convert.ToString(value);
- }
- private void CheckBox_A_Click(object sender, EventArgs e)
- {
- JHandler((sender as CheckBox), ref a, textBox1);
- }
- private void CheckBox_B_Click(object sender, EventArgs e)
- {
- JHandler((sender as CheckBox), ref b, textBox2);
- }
- private void CheckBox_C_Click(object sender, EventArgs e)
- {
- JHandler((sender as CheckBox), ref c, textBox3);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment