Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Code that handles click events
- private void number_Click(object sender, EventArgs e)
- {
- if((txtResult.Text == "0")||(operation))
- {
- txtResult.Clear();
- }
- //Cast button to the object sender
- operation = false;
- Button button = (Button)sender;
- //If the button pressed is a "." then check if the txtResult already contains
- //a ".", if it does contain a "." then do nothing
- if (button.Text == ".")
- {
- if (!txtResult.Text.Contains("."))
- {
- txtResult.Text = txtResult.Text + button.Text;
- }
- }else
- txtResult.Text = txtResult.Text + button.Text;
- }
- //Keyboard press event code
- private void num1_key(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == '1')
- {
- //If keyboard '1' pressed perform number_click()
- btn1.PerformClick();
- e.Handled = true;
- }
- }
Add Comment
Please, Sign In to add comment