private void Calculate_KeyPress(object sender, KeyPressEventArgs e) { switch (e.KeyChar.ToString()) { case "1": button1.PerformClick(); break; case "2": button2.PerformClick(); break; case "3": button3.PerformClick(); break; case "4": button4.PerformClick(); break; case "5": button5.PerformClick(); break; case "6": button6.PerformClick(); break; case "7": button7.PerformClick(); break; case "8": button8.PerformClick(); break; case "9": button9.PerformClick(); break; case "0": button0.PerformClick(); break; case "+": PlusBtn.PerformClick(); break; case "-": SubtractBtn.PerformClick(); break; case "*": MultipleBtn.PerformClick(); break; case "/": DevideBtn.PerformClick(); break; case "=": EqualBtn.PerformClick(); break; case "\r": EqualBtn.PerformClick(); break; case " ": EqualBtn.PerformClick(); break; case "(": LeftBracketBtn.PerformClick(); break; case ")": RightBracketBtn.PerformClick(); break; case ".": PointBtn.PerformClick(); break; case "%": Percent.PerformClick(); break; case "\b": CEBtn.PerformClick(); break; default: break; } }
// Zorgen dat het toetsenbord gebruikt kan worden private void NumPadInput(object sender, KeyPressEventArgs e) { switch (e.KeyChar.ToString()) { case "0": ZeroBtn.PerformClick(); break; case "1": OneBtn.PerformClick(); break; case "2": TwoBtn.PerformClick(); break; case "3": ThreeBtn.PerformClick(); break; case "4": FourBtn.PerformClick(); break; case "5": FiveBtn.PerformClick(); break; case "6": SixBtn.PerformClick(); break; case "7": SevenBtn.PerformClick(); break; case "8": EightBtn.PerformClick(); break; case "9": NineBtn.PerformClick(); break; case "*": TimesBtn.PerformClick(); break; case "/": DivideBtn.PerformClick(); break; case "-": SubtractBtn.PerformClick(); break; case "+": Addbtn.PerformClick(); break; case ",": DecimalBtn.PerformClick(); break; case ".": DecimalBtn.PerformClick(); break; case "c": ClearBtn.PerformClick(); break; // Twee keer op de "c" toets op het toetsenbord klikken voor een All Clear case "c" + "c": AllClearBtn.PerformClick(); break; default: break; } // De "Enter" toets op het toetsenbord de functie van de "=" toets toewijzen if (e.KeyChar == (char)Keys.Enter) { EqualBtn.PerformClick(); } }