473,394 Members | 1,266 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,394 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 6845
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.