Drop within a multi-line TextBox

2 posts, 0 answers
  1. GEB
    GEB avatar
    228 posts
    Member since:
    Dec 2008

    Posted 15 Oct 2009 Link to this post

    I am successfully dragging a string from a ListBox to a multi-line TextBox.  However, as the user is dragging into the TextBox, I'd like to show the insertion point as the user drags across the TextBox, allowing the user to drop to an insertion point of their choice.  Is there an example, or any ideas as to how this can be accomplished?

    The way I'm dropping this within the TextBox today is to drop into the TextBox's current insertion point (TextBox.SelectionStart).  But, this does not allow the user to physically see where the string will be dropped as it is being dragged, and it does not allow the user to "move" the insertion point during the drag operation.  Any ideas would be appreciated.  I would think this is something that several applications could use.

  2. Miroslav
    Miroslav avatar
    922 posts

    Posted 20 Oct 2009 Link to this post

    Hi GEB,

    Unfortunately the Silverlight TextBox does have a very limited API and you cannot retrieve the text offset index based on the mouse position.

    I believe that there may be a way to estimate the current row in the TextBox if the text in the text box is not wrapped. You can inherit the text box and get its scroll viewer. Then you can use its ExtentHeight to get the total height of the text and then do some calculation to find the text row height and use the mouse position to display an overlay marker and then insert something there. This though sounds like a hacky solution and I cannot think of a workaround if the text is wrapped.

    Best wishes,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft R3 2016 release webinar banner
Back to Top