473,378 Members | 1,330 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,378 software developers and data experts.

Inserting and deleting text in a RichTextbox

Hi. This should be so easy, but I don't get it. Let say I have
RichTextbox1 and I want to insert some text at the current insertion point,
or at the beginning of selected text (if there is any). How is this done?
Also, how do I delete the current selection? Thanks.
Nov 21 '05 #1
2 6045
Hi,
SelectedText property is the key to perform all these operations. This
property either inserts text at the current insertion point or replaces
current selection. For deleting current selection, you may simply assign an
empty string ("" or String.Empty) to the SelectedText.

One way for inserting new text at the beginning of the selection is
something like this:

Dim selLength As Integer = RichTextBox.SelectionLength
RichTextBox.SelectionLength = 0
RichTextBox.SelectedText = <text to insert>
RichTextBox.SelectionLength = selLength

HTH

"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:O9********************@twister.nyroc.rr.com.. .
Hi. This should be so easy, but I don't get it. Let say I have
RichTextbox1 and I want to insert some text at the current insertion point,
or at the beginning of selected text (if there is any). How is this done?
Also, how do I delete the current selection? Thanks.

Nov 21 '05 #2
Ah, so that's how you do it. Thank you.

"Shiva" <sh******@online.excite.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,
SelectedText property is the key to perform all these operations. This
property either inserts text at the current insertion point or replaces
current selection. For deleting current selection, you may simply assign an empty string ("" or String.Empty) to the SelectedText.

One way for inserting new text at the beginning of the selection is
something like this:

Dim selLength As Integer = RichTextBox.SelectionLength
RichTextBox.SelectionLength = 0
RichTextBox.SelectedText = <text to insert>
RichTextBox.SelectionLength = selLength

HTH

"Clark Stevens" <cy*********@hotmail.com> wrote in message
news:O9********************@twister.nyroc.rr.com.. .
Hi. This should be so easy, but I don't get it. Let say I have
RichTextbox1 and I want to insert some text at the current insertion point, or at the beginning of selected text (if there is any). How is this done?
Also, how do I delete the current selection? Thanks.

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: kangoo | last post by:
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...
2
by: Hendrik | last post by:
Hi I have searched extensively for help on inserting text at the position of the mouse pointer in a text box as the final step of drag and drop process What I have come with is listed below - the...
5
by: Alvo von Cossel I | last post by:
hi, i have a word processor with a richtextbox in the center of the screen. if you paste an image into the richtextbox, it will appear. however, with my openfiledialog, only some text will...
1
by: gabe | last post by:
I am looking for a way to mimic some of the functionality of a web page without writing html (or I am looking to someone to point out something really obvious that I am over looking) Currently I...
5
by: genojoe | last post by:
I have a RTF control on a form and want to insert text programmatically. I thought it would be easy but it does not turn out that way. Can someone refer me to an Internet article that covers this...
3
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to...
1
by: farrukhqadri786 | last post by:
Hi! I have an imageList and a richtextbox in a C# form. I want to insert image from imageList into a richtextbox. I have found the following code on net but it does'nt work. ...
3
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
One more for today.... As I add more and more lines to my RichTextBox the array that holds its strings gets bigger and bigger and the vertical scroll bar gets smaller and smaller until the...
0
by: ajithmanmadhan | last post by:
hi pls help me out in inserting text into a richtextbox. the situation is like this:: i want to insert a string say "hello" at a particular location in the rich textbox. The particular...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.