473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

richTextBox.Text.Remove()

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
3 21026
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Leitgeb | last post by:
RichText has 2 properties for setting text color and text. RichTextBox.SelectionColor = Color.Black ; RichTextBox.SelectionText = "Hello World" ; How do I set yello color background for...
4
by: Just Me | last post by:
In a RichTextBox I'm displaying RichText . Sometimes I search the Text property string and sometime the RtfText string. I need to know what is used for end-of-line in both the RtfText and Text...
10
by: D Steward | last post by:
I can't seem to add a newline (/n) to get a richtextbox control to display text on successive lines. The text that I type is overwritten. How do I remedy this My example richTextBox->Multiline...
1
by: Benny Raymond | last post by:
I have lines of data coming from a server being written to a RichTextBox... The problem is that if I let this program run for a long period of time there are hundreds of lines of text showing up in...
2
by: Al | last post by:
Hi, Is there any way to replace a character at a position? Without cussing the RichTextBox to scroll. For example the following code will replaces the by removing but the side effect is that it...
3
by: AxOn | last post by:
Hi, I have an application with a Save function. I want to be able to have several tabs(each containing a RichTextBox, created at runtime) open in a tabControl and save the text from each...
1
by: eBob.com | last post by:
After a lot of debugging effort I have to conclude that it does. Or at least can. I take a substring (RichTextBox.Text.Substring) before setting SelectionStart and after and get a different...
0
parkavi
by: parkavi | last post by:
hi all........ i am doing my Project VB.NET(2005). i want to know, how to print a RichTextBox Text Programmatically(Without Using PrintDialogBox)... plz help me to do...
7
by: Claire | last post by:
Hi, Is there an easy/nice way to assign the contents of a stringcollection to richtextbox.lines rather than doing the following please? foreach(string str in _EmailErrors) { rtb.Text += str;...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.