我想要一个按钮来删除文本框中的最后一个字符,比如Windows计算器中的左箭头按钮
private void button15_Click(object sender, EventArgs e)
{
}
答案 0 :(得分:2)
这个怎么样?
private void button15_Click(object sender, EventArgs e)
{
string sYourText = txtYourTextBox.Text;
if (!String.IsNullOrEmpty(sYourText)){
sYourText = sYourText.substring(0, sYourText.Length -1);
txtYourTextBox.Text = sYourText;
}
}
答案 1 :(得分:1)
除非没有其他要求,否则这就是您所需要的
var text = "something"; //your TextBox.Text
if (text.Length > 0)
text = text.Remove(text.Length - 1);
答案 2 :(得分:1)
private void button15_Click(object sender, EventArgs e)
{
var text = txtSomething.Text;
txtSomething.Text = text.Remove(text.Length - 1);
}