Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8736391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:17:38+00:00 2026-06-13T10:17:38+00:00

If I drag (back to front) to select text in a RichTextBox, the Selection.Text

  • 0

If I drag (back to front) to select text in a RichTextBox, the Selection.Text matches the actual selection.
However, If I drag (front to back) to select text in that same RichTextBox, the Selection.Text is always an empty string.

The reason I need this information, is that after re-parsing (this involves clearing all the text and repopulating it) the text in the RichTextBox, I need to return the caret to the original position.

My goal is to get the offset of the start of the selection. I can use that to get a string that stops there, which I will use to replace the caret at the end of the parsing.

if (String.IsNullOrWhiteSpace(Selection.Text))
                restartPosition = activeRun.ContentStart.GetOffsetToPosition(CaretPosition.GetInsertionPosition(LogicalDirection.Forward));
            else
                restartPosition = activeRun.ContentStart.GetOffsetToPosition(Selection.Start);

The key is in that ‘if’ statement. If there is no selection, I can just use the text pointer for where the cursor is. If however there is a selection, I need the beginning of it. Ironically, if it were failing in the other direction it wouldn’t be an issue.

Is there a way to accurately retrieve the selection? Microsoft’s implementation seems a bit flawed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:17:39+00:00Added an answer on June 13, 2026 at 10:17 am

    So, it wasn’t broken. Changing the CaretPosition clears the selection. That was what was happening. Works like a champ now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write some front end Javascript tests that can test drag
I have a nested drag and drop list which return json formattet string. I
I've got a drag and drop script that uses readAsArrayBuffer() . The length of
I know that when a drag/drop operation is completed, upon receiving a MouseUp or
Most view in ios are draggable like in safari that I can drag and
I'm writing a new web application that needs to support drag and drop operations
I am working on a drag and drop puzzle game and the Activity that
I'm getting back into .NET development after a couple years and it seems that
I'm using visual studio 2008 and I've created a stored procedure that selects back
I am trying to send the results of the current drag drop state back

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.