怎样用button来一个一个删除字符串啊?

gxt291371609 2012-03-25 11:01:06
假如我输入输入了一串字符,我想用button来一个一个删除字符串,找不到那个函数,还请大家帮帮忙!谢谢
...全文
105 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cnwin 2012-03-25
  • 打赏
  • 举报
回复
就是像退格功能,截字符串就可以啊。
ojekleen 2012-03-25
  • 打赏
  • 举报
回复
button 有onclick 事件,在事件中删除字符串的最后一位?

private void butdelete_OnClick(object sender,Events e)
{
string str=this.txbstr.Text.Trim();
str=str.SubString(0,str.Length-2);
this.txbstr.Text=str;
}
porschev 2012-03-25
  • 打赏
  • 举报
回复


private string DeleStr(string str)
{
if (str.Length > 0)
return str.Remove(str.Length - 1);
else
return str;
}

protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = DeleStr(TextBox1.Text);
}

  • 打赏
  • 举报
回复

//按钮事件
private void button2_Click(object sender, EventArgs e)
{
//让文本框获取焦点
this.textBox1.Focus();
//模拟退格键
SendKeys.Send("{BackSpace}");
}
polk6 2012-03-25
  • 打赏
  • 举报
回复
++

[Quote=引用 1 楼 ojekleen 的回复:]

button 有onclick 事件,在事件中删除字符串的最后一位?
C# code

private void butdelete_OnClick(object sender,Events e)
{
string str=this.txbstr.Text.Trim();
str=str.SubString(0,str.Length-2);
this.txbstr.Text……
[/Quote]

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧