473,324 Members | 2,417 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,324 software developers and data experts.

Position of the scroll in a TextBox

If a multiline text window is "scrolled", how can I get ho much it has been
scrolled from the begin of the document?

Thanks,
Fabio
Jan 14 '06 #1
3 6831
On Sat, 14 Jan 2006 20:10:44 GMT, "Fabio Cannizzo"
<fc*****************@london.edu> wrote:
If a multiline text window is "scrolled", how can I get ho much it has been
scrolled from the begin of the document?

Thanks,
Fabio


You can do this by lines or by characters.

1 Characters:

The total number of characters is myTextBox.Text.Length, the character
position at the start of the current line is
myTextBox.GetFirstCharIndexOfCurrentLine(). From those two you can
get an idea of where you are in the text.

2 Lines:

The total number of lines is myTextBox.Lines.Count. To find the
current line use GetFirstCharIndexOfCurrentLine() as above and then
use GetLineFromCharIndex(int charIndex) to find the current line.
Again this will give you an idea of where you are in the text.

The Object Browser is your friend in things like this.

rossum
--

The ultimate truth is that there is no ultimate truth
Jan 14 '06 #2
Hi Rossum.

Thanks for your mail.

I think that GetFirstCharIndexOfCurrentLine() does not solve my problem.
Current line, is the line where the caret is located. However, if the text
has been scrolled using the default scrollbars, that could well be outside
the screen. I need to know the position of the screen window with respect to
my text document.

For instance, if I take the client coordinates (1,1), if there was a way to
know which character correspond to that position, that would do it.

Regards,
Fabio
"rossum" <ro******@coldmail.com> wrote in message
news:5p********************************@4ax.com...
On Sat, 14 Jan 2006 20:10:44 GMT, "Fabio Cannizzo"
<fc*****************@london.edu> wrote:
If a multiline text window is "scrolled", how can I get ho much it has
been
scrolled from the begin of the document?

Thanks,
Fabio


You can do this by lines or by characters.

1 Characters:

The total number of characters is myTextBox.Text.Length, the character
position at the start of the current line is
myTextBox.GetFirstCharIndexOfCurrentLine(). From those two you can
get an idea of where you are in the text.

2 Lines:

The total number of lines is myTextBox.Lines.Count. To find the
current line use GetFirstCharIndexOfCurrentLine() as above and then
use GetLineFromCharIndex(int charIndex) to find the current line.
Again this will give you an idea of where you are in the text.

The Object Browser is your friend in things like this.

rossum
--

The ultimate truth is that there is no ultimate truth

Jan 16 '06 #3
On Mon, 16 Jan 2006 00:22:25 GMT, "Fabio Cannizzo"
<fc*****************@london.edu> wrote:
For instance, if I take the client coordinates (1,1), if there was a way to
know which character correspond to that position, that would do it.


myTextBox.GetCharIndexFromPosition(System.Drawing. Point) returns the
integer character index of the character at a given position, in your
case (1, 1). This seems to be what you want.

rossum

--

The ultimate truth is that there is no ultimate truth
Jan 16 '06 #4

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

Similar topics

1
by: Boniface Frederic | last post by:
Hello, I have frame displaying the last posted messages. I set <meta http-equiv="refresh" content="5"/> to automatically refresh the frame every 5s My problem is; if I scroll the frame to see...
2
by: GrantS | last post by:
I am trying to convert the VB.Net code example povided by http://authors.aspalliance.com/JimRoss/Articles/MaintainScrollPos.aspx into C# (ASP.Net)without success. No errors are thrown in the VB...
4
by: ojorus | last post by:
Hi! I just wonder how I can save a page's scroll position with javascript. (i'm not a javascript developer) I have a PHP-page with two columns; the left contains a lot of thumbnails, and the right...
1
by: Ted | last post by:
I am trying to return the vertical scroll position of a rich textbox control using Access 2000. It seems to work for the horizontal scroll bar, but not the vertical. Code follows: Option...
1
by: JC | last post by:
I'm sure you've all seen the save scroll position from 4 guys from rolla which can be found here > http://aspnet.4guysfromrolla.com/articles/111704-1.aspx BUT try to get that to work AND still be...
6
by: Colin McGuire | last post by:
Hello experts, this is a repost but I have been (much) more clear. I want to know the position of the horizontal scrollbar in a textbox as a percentage - if the horizontal scrollbar is hard...
2
by: Rich | last post by:
Greetings. I have a child form inside an MID parent form. The child form is wider than the MID parent form. The child form contains a number of textboxes which are positioned from left to...
0
by: kennji | last post by:
i got a textbox(multiline). I want to make it scroll down as new input is added but it always return to the top of the textbox. What is the codes needed in Visual Web Developer to make it scroll...
7
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client...
12
Frinavale
by: Frinavale | last post by:
I think I'm trying to do something impossible. I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.