Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Insertion Point's location in a RichTextBox

Insertion Point's location in a RichTextBox

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bneacetp
    wrote on last edited by
    #1

    How would I capture the X and Y point location of the user's insertion point in a System.Windows.Forms.RichTextBox instance? :confused: Happy Programming and may God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp

    L 1 Reply Last reply
    0
    • B bneacetp

      How would I capture the X and Y point location of the user's insertion point in a System.Windows.Forms.RichTextBox instance? :confused: Happy Programming and may God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp

      L Offline
      L Offline
      LongRange Shooter
      wrote on last edited by
      #2

      I've been hesitant to answer this since I don't have all of the specific calls to make...but lets assume this: You have an RTF box and the cursor is positioned somewhere inside a valid location in that control. You have a button which they press and it that button is [Insert Clipboard] for example. First you get the cursor location by getting this.Cursor.Postion and maybe even you can get this.Cursor.Position.X and .Y but it's not important. The part I cannot remember is you make a call (into the control?? or into Application???) which translates the relative location of the cursor on the desktop to the relative position of the cursor within the control. Maybe Nick can add to the reply as to the specific call....but if not, you have a starting point. This signature left intentionally blank

      B 1 Reply Last reply
      0
      • L LongRange Shooter

        I've been hesitant to answer this since I don't have all of the specific calls to make...but lets assume this: You have an RTF box and the cursor is positioned somewhere inside a valid location in that control. You have a button which they press and it that button is [Insert Clipboard] for example. First you get the cursor location by getting this.Cursor.Postion and maybe even you can get this.Cursor.Position.X and .Y but it's not important. The part I cannot remember is you make a call (into the control?? or into Application???) which translates the relative location of the cursor on the desktop to the relative position of the cursor within the control. Maybe Nick can add to the reply as to the specific call....but if not, you have a starting point. This signature left intentionally blank

        B Offline
        B Offline
        bneacetp
        wrote on last edited by
        #3

        Thanks for your help. I finally figured out how to do this and it might help others who might need or want to know how to do this. Below is the bit of code I used to get the Point location of the insertion point. rchEdit.GetPositionFromCharIndex(rchEdit.SelectionStart) This did it. GetPositionFromCharIndex(...) when passed the selection start index, returns a Point instance at the insertion point's index (or at the beginning of a selection). Happy Programming and may God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups