473,388 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Help on "GetPositionFromCharIndex(ByVal index As Integer) As Point"

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
Nov 21 '05 #1
6 4620
Martin,
Have you tried RichTextBox.SelectionStart & RichTextBox.SelectionLength,
both inherited from TextBoxBase?

Hope this helps
Jay
"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:52********************************@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

Nov 21 '05 #2

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]"
<Ja************@msn.com> wrote:
Martin,
Have you tried RichTextBox.SelectionStart & RichTextBox.SelectionLength,
both inherited from TextBoxBase?

Hope this helps
Jay
"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:52********************************@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


Nov 21 '05 #3
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" <ni**@nospam.invalid> wrote in message
news:ri********************************@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]"
<Ja************@msn.com> wrote:
Martin,
Have you tried RichTextBox.SelectionStart & RichTextBox.SelectionLength,
both inherited from TextBoxBase?

Hope this helps
Jay
"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:52********************************@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

Nov 21 '05 #4

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]"
<Ja************@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" <ni**@nospam.invalid> wrote in message
news:ri********************************@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]"
<Ja************@msn.com> wrote:
Martin,
Have you tried RichTextBox.SelectionStart & RichTextBox.SelectionLength,
both inherited from TextBoxBase?

Hope this helps
Jay
"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:52********************************@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


Nov 21 '05 #5
Martin,
In case the user had any text selected, saving SelectionLength (in addition
to SelectionStart) will save the "selection" as well.

If there is "There is no editing or any modifying in the box." it may not be
as important. However as soon as a user had text selected & it (the fact
that there was a selection) disappears they may get upset...

Its similar to VB6 add-ins that clear the clipboard when they start, simply
as that's the only way to set custom toolbar icons.

Hope this helps
Jay

"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:ls********************************@4ax.com...

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]"
<Ja************@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" <ni**@nospam.invalid> wrote in message
news:ri********************************@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]"
<Ja************@msn.com> wrote:

Martin,
Have you tried RichTextBox.SelectionStart & RichTextBox.SelectionLength,
both inherited from TextBoxBase?

Hope this helps
Jay
"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:52********************************@4ax.co m...
> 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

Nov 21 '05 #6

Jay,
Good point thx. We didn't think of that because we are working on a
read only box. We have that working now.
Martin

On Wed, 23 Feb 2005 09:05:53 -0600, "Jay B. Harlow [MVP - Outlook]"
<Ja************@msn.com> wrote:
Martin,
In case the user had any text selected, saving SelectionLength (in addition
to SelectionStart) will save the "selection" as well.

If there is "There is no editing or any modifying in the box." it may not be
as important. However as soon as a user had text selected & it (the fact
that there was a selection) disappears they may get upset...

Its similar to VB6 add-ins that clear the clipboard when they start, simply
as that's the only way to set custom toolbar icons.

Hope this helps
Jay

"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
news:ls********************************@4ax.com.. .

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]"
<Ja************@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" <ni**@nospam.invalid> wrote in message
news:ri********************************@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]"
<Ja************@msn.com> wrote:

>Martin,
>Have you tried RichTextBox.SelectionStart & RichTextBox.SelectionLength,
>both inherited from TextBoxBase?
>
>Hope this helps
>Jay
>
>
>"Martin Heuckeroth" <ni**@nospam.invalid> wrote in message
>news:52********************************@4ax.c om...
>> 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
>


Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: udayt | last post by:
Hi, My application needs to calculate the sort order of an index key (whether the index key is descending or ascending). The user may connect to MS7 or MS2K servers. As far as I know, the...
1
by: KlaasIMN | last post by:
Using a combobox I want to retrieve the index of a given value in a combobox. object sel = combo.SelectedValue; string selectedvalue = sel.ToString(); ComboBox.ObjectCollection items =...
3
by: Woody Splawn | last post by:
For reasons I have not yet identified my Help, Search and Help, Index has quit working. That is, in the VB IDE, from the Help menu, I can select Dynamic help or Contents and things work as...
1
by: Manuel Canas | last post by:
Hi There, I have been batleing with this now that I'm at the end of my rop here. What I'm doing here is this; 1 - retrieving some data from the database with a data reader (with a search...
5
by: vj_dba | last post by:
Hi group, I have a table say with 10000 records and 10 columns initially, I created an index say i1, after few days I altered the table by adding 10 new columns and 90000 rows of records summing...
9
by: hapa | last post by:
I have a problem in this C++ program That i have written. help me with the problem that i have mentioned below I have written this program to convert a integer to binary digit problem one is that...
5
by: wazzup | last post by:
My task is Create a program to read a simple integer expression and display the result. "Simple" means no parentheses are allowed and only the +, -, *, and / operators are allowed. I think...
3
by: ayman723 | last post by:
hi I had this problem where I was asked to : Write a program that compares and records the time taken to sort an array of social security numbers using four sorting algorithms. The program...
1
by: w33d5 | last post by:
I'm looking for a little help in making an index file to read the subdirectories in the same folder and display the links in a table. i am loading photo galleries using google's picasa onto my...
4
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.