Is there a way to put the cursor at a specific location in a RichTextBox?

Is there a way to put the cursor at a specific location in a RichTextBox?
The following code places the cursor at the start of a RichTextBox:
    RichTextBox RTbx
    RTbx.Focus();
    TextPointer tp = RTbx.CaretPosition;
    tp = tp.DocumentStart;
    RTbx.CaretPosition = tp;
Not sure how to place it at a specific location other than start and end.
The RichTextBox has contents.  At this point in the code, I do know the specific "word" in the contents, as well as the position (number of chars) where that word is located.  I just need to programmatically place the cursor at that location.
bhs67

Oh sorry, I see I missed something out my original reply.
I have markup:
<Grid>
<RichTextBox Name="rtb">
<FlowDocument>
<Paragraph >This is the first paragraph</Paragraph>
<Paragraph >TSecond paragraph is here</Paragraph>
</FlowDocument>
</RichTextBox>
</Grid>
Code - this is the window contentrendered event
private void Window_ContentRendered(object sender, EventArgs e)
rtb.Focus();
// TextPointer moveTo = rtb.CaretPosition.GetNextInsertionPosition(LogicalDirection.Forward);
TextPointer moveTo = rtb.CaretPosition.GetPositionAtOffset(9, LogicalDirection.Forward);
if (moveTo != null)
rtb.CaretPosition = moveTo;
I see the cursor between the t and he of the second "the".
Note that there are numerous other options such as the commented out line.
Hope that helps.
Recent Technet articles: Property List Editing;
Dynamic XAML

Similar Messages

  • Is there a way to put the same event on multiple icloud calendars?

    Is there a way to put the same calendar entry on multiple calendars?  I have five children and most of them use their iTouch to keep there calendar.   My calendar is on icloud and I'd love it if they could see only their events but I need to see all of them.   Many of the events affect more than one child.

    As follow up to the above question,  I am the person putting items on the calendars.  I am not just trying to see calendars that they are maintaining. 

  • Is there a way to put the bluetooth icon on the homepage?

    I pair my iphone with my car when I'm driving. Is there a way to put the bluetooth icon on the homepage so I don't have to go through settings to turn the bluetooth on and off?
    I don't like to leave the bluetooth on all the time because it drains the battery, but it's kinda a pain to have to go through settings everytime I want to use this feature.
    On my last cell phone I could assign a "hot key" to automatically turn the bluetooth on and off. I really liked that. This bluetooth system seems a little dated to me.

    No not yet, hopfully soon.

  • When streaming a movie from an imac to apple tv, is there a way of putting the imac display off? I find it a waste having the screen on in another room. Any advice?

    When streaming a movie from an imac to apple tv, is there a way of putting the imac display off? I find it a waste having the screen on in another room. Any advice?

    No problem.
    This is a user forum so you are not addressing Apple. There's nothing to fix, that's how home-sharing works. There would be no way for the ATV to recognize your library and display content if the computer is in sleep mode.
    You can always airplay from an IOS device or use icloud if you don't wish to keep the computer on.

  • Is there any way to put the mini calendar on the monthly calendar as in Leopard?

    I downloaded Lion about a month ago and the only dislike is ical. For one is there any way to put the mini calendar on the monthly display as it was in Snow Leopard. It makes it much easier instead of flip flopping back and forth to see last month or previous months?

    Nope

  • Is there a way to force the cursor into a string control when a vi is called

    In a .vi I'm wrighting I need to input a new serail number at the beginning of each run. Is there a way to force the cursor into the string control box every time the start screen returns? eliminating the need for the operator to move the mouse around and click.
    I would like to THANK all that have replied to my questions in the past. It has been a big help!
    Thanks
    TeBlues

    ah, problem solved.  what a community.
    Message Edited by Space_Flight on 11-20-2006 10:08 AM
    Attachments:
    keyfocus.jpg ‏83 KB

  • I brought a new computer is there any way to put the items that i have on my iphone and ipad on my itunes with out erasing and reformating my divices.

    I brought a new computer is there any way to put the items that i have on my iphone and ipad in my itunes. I know the music and apps i paid for but what about the songs and photos. that are not paid for. and having it sync with out it telling me that it has to erase all my things.

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • Is there a way to change the cursor hotspot systemwide on Mountain Lion?

    Hello community.
    Is there a way to change the cursor hotspot on Mountain Lion, systemwide?
    Like editing the original cursor file (or downloading one) and replacing the original one?
    Reason: when I enlarge the arrow, the "absoulute" tip (top of the white outline) gets distant from the internal tip (top of the black core), so sometimes the white outline needs to stick out if I want to click the approprate area - because the hotspot is on the internal tip. To me it's counter-intuitive. I would prefer to have the hotspot on the absolute edge of the cursor (tip of the white outline). This is not debatable - this is my private preference, and I've read today that it's not only mine - there is a number of users who want the same.
    I know it's always been like this on Macs, so please avoid questions like "why to you want that", answers like "get used to it" or any kind of hostility, for these are useless. The quiestion is how can I change it, if possible.
    Thanx guys!

    I don't know how you get to the System folder in Mavericks; and even if I found the folder with the alternative cursors in it, I would have no way of switching to any of them.  The designers have obviously not anticipated that anyone would wish to do this.
    The System Preferences has an adjustment under Accessibilty which allows the user to change the size of the cursor, but nothing else.
    So I guess that there is no way to make the change without actually re-engineering the System somehow.
    If someone can find a way, I will be most pleased to be enlightened; only please make the directions explicit.

  • Is there any way to make the cursor appear larger in Mac OS X?

    Wow, love my 27" screen, but have trouble finding the cursor! Is there any way to make the cursor appear larger? Perhaps adjustable for fine print capture?
    Thanks!

    System Preferences -> Universal Access -> Mouse -> Cursor size
    However, I prefer using Mouse Locator (free download)
    <http://www.versiontracker.com/dyn/moreinfo/macosx/26157>
    I like this Mouse Locator Graphic
    <http://homepage.mac.com/douglasn/locatorexchange/AD/1/MouseLocator.png>
    I also enjoy my 27" iMac. It is just so nice withing on it.
    Message was edited by: BobHarris

  • Is there a way to put the songs from my ipod to my itunes???

    I think I did something and it erased some of my songs in the library but they are still on my ipod. what happened to the songs??? and is there a way to put the songs from my ipod onto my itunes?

    Perhaps you may
    i still
    have the music files on your PC -- but not seen in iTunes.
    Check using Windows Explorer in 'My Music\iTunes\iTunes Music\...' for folders containing your music (or wherever you keep your music folders). If it is there, we can get iTunes to recognize it. Try one or both of these:
    --- In iTunes choose: Edit==>Preferences==>Advanced tab. Select 'Change' and browse to the music folder in your PC drive (if it isn’t already). Click OK to save that setting.
    --- In iTunes choose: File==>’Add Folder to Library’ & browse to the music folder in your PC drive. Click OK.
    Also check in your Recycle Bin to see if you accidentally deleted it. If so, ‘Restore’ it back to it’s original spot.
    Then try running a search using Windows Explorer (or similar) for files with the extensions of: m4a, m4p, MP3,
    i OR
    with the partial names of the songs you are missing.
    Do all the above before you decide that they have been completely erased from your hard drive.
    If your music files are truly gone, and you have some or all of your music files on your iPod, these links will give you
    i several
    methods of recovering whatever songs remain on your iPod; some free, some third-party software, some more comprehensive for restoring playlists , ratings, counts, etc. Read them and their associated links before deciding on a strategy that works for you.
    How to import songs from your iPod to iTunes
    Use the iPod in its alter ego - that of portable computer disk drive
    Copying music from iPod to computer
    Copying Songs from Your iPod to a Mac or PC
    After recovering your song files, consider developing a backup strategy for just this type of situation. Below are some very good threads to read on the subject:
    StarDeb55, "Backing up music Please Help" #1, 10:04pm Jun 24, 2005 CDT
    Buegie, "Backing Up?" #1, 09:16am Jun 15, 2005 CDT

  • Is there any way to put the values inthe system matrix which is non editabl

    is there any way to put the values inthe system matrix which is non editable...
    this Q is not that much priority since i had achieved the requirement other way round by having user defined matrix ... but if i get the way for this it will help my add on performance much better...

    Hi Raj, I didnt get all the details but here some ideas how you can solve your issue:
    Depending in the system form you are working you can always use a DBDataSource in order to manipulate the rows in a matrix. It's much better as using the objects of the matrix itself. In this case you can use:
    oMatrix.FlushToDataSource()
    oDBDsource.SetValue("U_Quan", pVal.Row, "101")
    oMatrix.Clear()
    oMatrix.LoadFromDataSource()
    As you can see in SetValue i'm obtaining the Column, then the row number and then setting a NEW value for this cell.
    Please consider if you can use DBDataSource instead of UserDataSource.
    If the answer is yes then you can use the following:
    oMatrix.FlushToDataSource()
    '//Get the line you want
    matrix.GetLineData(pval.row)
    '//Call the Userdatasource assigned to that column
    UserDataSource = UserDataSources.Item("ItmCode")
    '//Set the new value
    m_UserDS.ValueEx = "A02520"
    oMatrix.LoadFromDataSource()
    You can also use:
    oMatrix.Columns.Item("ItemName").Cells.Item(l_rownum).Specific.String = "A02520"
    In case you are not assigning the string in a combobox of course.
    Good luck!
    Felipe

  • HT201269 my IPOD touch completely died.  I just got a replacement.  Is there a way to put the songs that were on the old one onto the new one?

    My IPOD touch completely died.  It will not power up.  I bought a replacement.  Is there a way to transfer the music already purchased onto the new IPOD from Itunes?

    Just sync the new iPod with the computer that you used to sync the old iPod.

  • IPhone question:  when I receive a call from someone who is not in my contacts and I then decide to add that number to my contacts, is there a way to put it directly into a specific group?

    After receiving a call on my iPhone 4s I decide I want to add their number to a specific group in my contacts using the "Create New Contact" option.  When I do this it only is established in the "All Contacts" group.  Is there a way to add it directly to a specific group?

    hi, this thread already deals with the issue:
    How can I prevent getting calls from number that are not in my address book?

  • Is there a way to restrict the cursor at the end of a line in the source code editor??

    In the source code editor, the cursor will always follow where I click. But I wanna restrict it at the end of a line, just like other text editors do. Is there a option or sth? I can't put up with it any longer.
    Solved!
    Go to Solution.

    Hello morphe!
    The source editor in the LabWindows/CVI environment is constructed under the concept of virtual space.
    At the moment, in the current version of LabWindows/CVI, this is the default behavior, which cannot be changed from the editor preferences dialogs.
    Best regards,
    - Johannes

  • Is there a way to hide the cursor or change the cursor to a hand?

    Hi,
    I think the title is self explanatory. The reason I want to do it is because I'm developing a touchscreen interface and I reckon it would look better if I had a hand instead of a cursor or if I got rid of the cursor completely.
    Cheers,
    elmicko

    Yeah theres a way.
    Use method
    setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    ciao

Maybe you are looking for