Re: Help on "GetPositionFromCharIndex(ByVal index As Integer) As Point"
From: Martin Heuckeroth (nick_at_nospam.invalid)
Date: 02/23/05
- Next message: Oenone: "Stopping the CancelButton from closing a Dialog form"
- Previous message: Bob Hollness: "Re: Alway on top problem"
- In reply to: Jay B. Harlow [MVP - Outlook]: "Re: Help on "GetPositionFromCharIndex(ByVal index As Integer) As Point""
- Next in thread: Jay B. Harlow [MVP - Outlook]: "Re: Help on "GetPositionFromCharIndex(ByVal index As Integer) As Point""
- Reply: Jay B. Harlow [MVP - Outlook]: "Re: Help on "GetPositionFromCharIndex(ByVal index As Integer) As Point""
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Feb 2005 15:21:45 +0100
Jay,
Thx for being persistent. We took another and better look at the
SelectionStart and yes it works.
Btw why do you recommend that we save the SelectionLength also?
Martin
On Tue, 22 Feb 2005 12:03:48 -0600, "Jay B. Harlow [MVP - Outlook]"
<Jay_Harlow_MVP@msn.com> wrote:
>Martin,
>> Jay, thx for your answer but I believe that's not it.
>Again, have you tried it? :-|
>
>Are you asking where the mouse Cursor is or the text caret? Normally when
>people as for "save my position" its text caret (although they state
>"cursor"), in which case SelectionStart is what they are wanting. To get the
>Mouse Cursor position you can use Control.MousePosition, however I don't
>know of a .NET method to set the mouse position, IMHO moving the mouse
>Cursor can be rather disruptive to the user anyway :-|
>
>>>> So my guestion is how can we store the x,y coordinates of the cursor
>>>> in the richtextbox so we can restore the cursor position after the
>>>> refresh.
>
>Use RichTextBox.SelectionStart as it is the position of the caret in your
>RichTextBox. Rather then being row & column it is number of characters from
>the beginning of the RichTextBox.
>
>Something like:
>
> Dim position As Integer = RichTextBox1.SelectionStart
> RichTextBox1.Refresh
> RichTextBox1.SelectionStart = position
>
>I would recommend also saving the RichTextBox.SelectionLength as well.
>
>Hope this helps
>Jay
>
>"Martin Heuckeroth" <nick@nospam.invalid> wrote in message
>news:ripm11pset8qeoh7j0g1v2pieigjl40ac8@4ax.com...
>>
>> Jay, thx for your answer but I believe that's not it.
>>
>> There is no editing or any modifying in the box. I need to find a way
>> to read the coordinates/position where i am in the richtextbox before
>> i do a refresh and it resets so i can return it to where it was before
>> i did the refresh. Like when i scrolled down to row 255 the refresh
>> will return me to row 1 and i need to go back manuallly to row 255. We
>> are blank here en I need a solution to have that done for me instead
>> of looking up where i was.
>>
>> Martin
>>
>>
>> On Tue, 22 Feb 2005 09:58:29 -0600, "Jay B. Harlow [MVP - Outlook]"
>> <Jay_Harlow_MVP@msn.com> wrote:
>>
>>>Martin,
>>>Have you tried RichTextBox.SelectionStart & RichTextBox.SelectionLength,
>>>both inherited from TextBoxBase?
>>>
>>>Hope this helps
>>>Jay
>>>
>>>
>>>"Martin Heuckeroth" <nick@nospam.invalid> wrote in message
>>>news:52km11tcokkr02rto9m9qo1vp4te4qg4jo@4ax.com...
>>>> Hi,
>>>>
>>>> We are looking for a way to determine the x and y points of the cursor
>>>> in a richtext box.
>>>>
>>>> We made an VB.NET application with a couple of listboxes and one of
>>>> them is a richtextlistbox. After a refresh the cursor of the
>>>> richtextlistbox is reset and goes to top. And that's not a cool thing
>>>> when you are reading at the bottom of that box and have to look up the
>>>> point where your were reading manual to have it reset after another
>>>> refresh.
>>>>
>>>> So my guestion is how can we store the x,y coordinates of the cursor
>>>> in the richtextbox so we can restore the cursor position after the
>>>> refresh.
>>>>
>>>>
>>>> Dim nSearch As Integer = ListBoxSearchItems.SelectedIndex
>>>>
>>>> Dim nTeamroom As Integer = ListBoxTeamroom.SelectedIndex
>>>>
>>>> Dim nRow As Integer = RichTextBoxMemo.
>>>> Dim nColumn As Integer = RichTextBoxMemo.
>>>> RefreshDataSet()
>>>>
>>>> If (nSearch > -1) And (nSearch < ListBoxSearchItems.Items.Count)
>>>> Then ListBoxSearchItems.SetSelected(nSeach, True)
>>>>
>>>> If (nTeamroom > -1) And (nTeamroom < ListBoxTeamroom.Items.Count)
>>>> Then ListBoxTeamroom.SetSelected(nTeamroom, True)
>>>>
>>>>
>>>> SeekInfo()
>>>>
>>>>
>>>> We started playing with the "GetPositionFromCharIndex(ByVal index As
>>>> Integer) As Point" function but don't get that to work. Any code will
>>>> be apperciated.
>>>>
>>>> thx, Martin
>>>
>>
>
- Next message: Oenone: "Stopping the CancelButton from closing a Dialog form"
- Previous message: Bob Hollness: "Re: Alway on top problem"
- In reply to: Jay B. Harlow [MVP - Outlook]: "Re: Help on "GetPositionFromCharIndex(ByVal index As Integer) As Point""
- Next in thread: Jay B. Harlow [MVP - Outlook]: "Re: Help on "GetPositionFromCharIndex(ByVal index As Integer) As Point""
- Reply: Jay B. Harlow [MVP - Outlook]: "Re: Help on "GetPositionFromCharIndex(ByVal index As Integer) As Point""
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|