473,394 Members | 1,706 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.

Move Visible Portion of RichTextBox to Desired Line

Hello,

I have a RichTextBox that has a large number of lines, well in excess of the amount that can be seen without scrolling. Upon an event, such as clicking a button, I would like to move the viewable portion of the RichTextBox to be able to see that particular line. In other words, if the RichTextBox has 1000 lines of text, how can I force the viewable portion to start at, say, line number 123?

This is what I have tried so far:
RichTextBox1.SelectionStart = RichTextBox1.GetFirstCharIndexFromLine(123)
RichTextBox1.SelectionLength = 0
RichTextBox1.ScrollToCaret()

I pretty much know I am not setting the SelectionStart property to the right value, but I don't really understand what the SelectionStart property is referencing: line number, position in the file, etc. The help page says it gets or sets the starting point of text selected in the text box. What does it mean for text to be "selected"?
Thanks,

Andrew
Apr 10 '07 #1
2 2079
Killer42
8,435 Expert 8TB
...I pretty much know I am not setting the SelectionStart property to the right value, but I don't really understand what the SelectionStart property is referencing: line number, position in the file, etc. The help page says it gets or sets the starting point of text selected in the text box. What does it mean for text to be "selected"?
That would be "selected" like when you drag the mouse over the text, causing it to be highlighted with a blue (in my case) background. Like when you want to copy the text. If you set the selected length to 1 (or more) instead of zero, you should at least be able to see where your selection point is.
Apr 12 '07 #2
Killer42
8,435 Expert 8TB
Something else to consider. Are there actually 1,000 lines? Or are there a smaller number of long lines, wrapped around? There's probably a difference. Although I'm not familiar with the control in question, I would guess that it probably counts end-of-line delimiters. Or in other words, paragraph breaks (to use Word-speak).

However, I suspect your best line of attack will be to play with the selection properties to get a feel for them. Perhaps "reverse engineer" them by writing a simple event procedure to print them out as you manually change the selection.
Apr 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Vincent Yang | last post by:
I'm using Access 2002. My database is in Access 2000 format. I'm designing a form to collect responses to a 40-item questionnaire. I can fit four list boxes on a screen, so I plan to have 11 tab...
10
by: D Steward | last post by:
I can't seem to add a newline (/n) to get a richtextbox control to display text on successive lines. The text that I type is overwritten. How do I remedy this My example richTextBox->Multiline...
2
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
4
by: Juan Romero | last post by:
Hey guys, Does anyone know how to find out the visible lines in the richtextbox control? For example, let's say the control has 30 lines, but due to size it can only display 10. The current...
2
by: Mad Scientist Jr | last post by:
I have a bitmap (32 pixels high, 8192 pixels wide) that contains 255 images, each 32 pixels wide, that I would like to chop up into individual 32x32 bitmap files. Rather than spending hours in...
0
by: Vincent | last post by:
Dear all, I have implemented a class to export the content of RichTextBox to image in WYSISYG mode so that line breaks on the screen are the same as exported. C# Code: public struct...
10
by: laredotornado | last post by:
Hi, Does anyone have a cross-browser function that given an id of a DIV element, can move the DIV to an absolute x,y position on the screen? Thanks, - Dave
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
8
by: inFocus | last post by:
Hello, I am new to python and wanted to write something for myself where after inputing two words it would search entire drive and when finding both names in files name would either copy or move...
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
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?
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
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
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...
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...

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.