I am learning the C# programming language and am making a payroll application add-on for SAP business One. I have built a customized calculator that has various commands, adding, subtracting etc. I am using Visual Studio 2010.
The output “screen” is a rich textbox named ‘formula_display’.
I am able to input numbers and commands and they show properly on the formula_display from left to right i.e, 2 8 9 * <= etc
I also have input buttons for operands e.g (), <>, [] and {}
My problem:
If I type, 4 * () and then try to input some number, e.g 9 inside the brackets (by clicking inside the () in order to place the cursor there), I’m unable to do so because the the number will appear after the bracket, i.e 4 * ()9.
How do I modify my code to be able to fix the problem:
Code Snippet:
private void btn9_Click(object sender, EventArgs e)
{
if (inputStatus)
{
formula_display.Text += btn9.Text;
}
else
{
formula_display.Text = btn9.Text;
inputStatus = true;
}
}
Any help appreciated. I am using Windows Forms
Try something like this in WPF:
and something like this in WinForms: