问题描述
你好,
我在Windows窗体上工作,我正在使用一个richtextbox和一个按钮现在我的查询是什么,我想要在我的richtextbox上写的东西必须一个一个地消失点击该按钮
示例:假设我的richtextbox上写有123,然后点击该按钮前3必须消失然后2然后1 ...
我也启用了richtextboxs readonly属性为true并且我已将其最大长度设置为10
i尝试
Hello,
I am working on a windows form where i am taking a richtextbox and one button now what my query is that i want what so ever is written on my richtextbox must vanish one by one on the hit of that button
Example: lets say my richtextbox has 123 written on it then on the hit of that button first 3 must vanish and then 2 and then 1...
also i have enabled richtextboxs readonly property to true and i have set its max length to 10
i tried
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.Text = "\b";
}
但是它的工作失败了
but failed its working like
richTextBox1.Clear();
我也试过
also i tried
if (richTextBox1.TextLength != 0)
{
int x = richTextBox1.TextLength;
x += -1;
}
但我不知道该添加什么
ya如果光标位于中间,那么它必须逐一从当前位置删除文本
请帮帮我
谢谢&问候
Radix
but i dont know what to add further
ya and if the cursor is in the middle then too it must remove the text from its current location one by one
Please Please help me out
Thanks & Regards
Radix
推荐答案
<br />
richTextBox1.Text = richTextBox1.Text.Remove(richTextBox1.Text.Length - 1, 1);<br />
希望寻求帮助
Hope For Help
这篇关于按钮在C#中用作Backspace键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!