我正在尝试编写 MS Windows Calculator 的副本 - 只是为了锻炼我在我正在做的课程中获得的知识 - 我在编写Backspace密钥时遇到问题,但我不知道如何删除TxtResult.Text
(文本框)上的最后一个字符。那么,有人可以教我如何做到这一点吗?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ZigndSuperCalc
{
public partial class FrmZigndSC : Form
{
Int64 aux, result;
Int16 cont = 0;
bool sucess;
public FrmZigndSC()
{
InitializeComponent();
}
private void BtnSoma_Click(object sender, EventArgs e)
{
sucess = Int64.TryParse(TxtInput.Text, out aux);
result += aux;
TxtInput.Text = Convert.ToString(result);
TxtInput.Focus();
}
private void BtnCE_Click(object sender, EventArgs e)
{
TxtInput.Text = "0";
}
private void BtnC_Click(object sender, EventArgs e)
{
result = 0;
TxtInput.Text = "0";
}
private void BtnBackspace_Click(object sender, EventArgs e)
{
// write here a method to delete the last character from
}
}
}