Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 29th, 2005, 10:42 PM   #1
syntax-error
Newbie
 
Join Date: Jun 2005
Posts: 2
Rep Power: 0 syntax-error is on a distinguished road
How to detect cursor location and insert text???

If I have a rich text box on a form, that is filled with say 30 lines of text the user has inserted. Is there a way I can detect where the cursor is in that text and insert some pre-defined text at its location on a button click? For example:

"This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box.<!!!!the cursor is here!!!> This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box. This is some text in a rich text box."

How can I detect where the cursor is and insert some text at its location? Thanks.
__________________
Someone dropped ignorance in the gene pool.

Quote:
98% of the teenage population will try, does or has tried smoking pot. If you're one of the 2% who hasn't, copy & paste this into your signature
syntax-error is offline   Reply With Quote
Old Jun 29th, 2005, 11:27 PM   #2
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
I imagine the answer is waiting for you somewhere at msdn.microsoft.com

Wow I'm in a really unhelpful mood today, sorry. Not that I know the answer anyway.
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials.
--WilliamSChips on Slashdot
uman is offline   Reply With Quote
Old Jun 30th, 2005, 12:21 AM   #3
melbolt
Professional Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 254
Rep Power: 4 melbolt is on a distinguished road
textBox1.Text.Insert(textBox1.SelectionStart, string);


cheers
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote
Old Jun 30th, 2005, 2:42 AM   #4
syntax-error
Newbie
 
Join Date: Jun 2005
Posts: 2
Rep Power: 0 syntax-error is on a distinguished road
Melbolt, your method works, but I figured out you can do it with this code

textBox1.SelectedText = <SomeStringHere>;
__________________
Someone dropped ignorance in the gene pool.

Quote:
98% of the teenage population will try, does or has tried smoking pot. If you're one of the 2% who hasn't, copy & paste this into your signature
syntax-error is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:59 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC