By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,758 Members | 1,264 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,758 IT Pros & Developers. It's quick & easy.

richTextBox.Text.Remove()

P: n/a
Hi,

I'm trying to remove the last charater in a richTextBox. I though
richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but
it does nothing
(eg richTextBox.Text += "some new text"; works)

Thanks for your attention & solutions
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
kangoo <bo*@boo.com> wrote:
Hi,

I'm trying to remove the last charater in a richTextBox. I though
richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but
it does nothing
(eg richTextBox.Text += "some new text"; works)

Thanks for your attention & solutions


string text = richTextBox.Text;
richTextBox.Text = text.Remove(text.Length - 1, 1);

As for the [richTextBox.Text += "some new text";] statement, using
RichTextBox.AppendText(string) would probably be more efficient there.
Nov 15 '05 #2

P: n/a
kangoo wrote:
Hi,

I'm trying to remove the last charater in a richTextBox. I though
richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but
it does nothing
(eg richTextBox.Text += "some new text"; works)

Thanks for your attention & solutions

richTextBox.Text = richTextBox.Text.Remove(richTextBox.Text.Length - 1, 1).

Notice assignment. It should always be when you use strings.

Nov 15 '05 #3

P: n/a
Dmitry Kostenko wrote:
kangoo wrote:
Hi,

I'm trying to remove the last charater in a richTextBox. I though
richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but
it does nothing
(eg richTextBox.Text += "some new text"; works)

Thanks for your attention & solutions


richTextBox.Text = richTextBox.Text.Remove(richTextBox.Text.Length - 1, 1).

Notice assignment. It should always be when you use strings.


thx u and C# learner
didn't know that
:)
Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.