How can I scroll automatically to certain line in C# richTextBox - c#

I have a rich textbox that is loaded from a text file.
each time I click a certain button, the yellow bar moves to highlight the next line as illustrated in the picture.
the problem is, when the textbox size is not enough to show the complete text, I want to make the yellow bar automatically scroll to the first line that is not shown without moving manually the scroll bar.
how can I do this?

Related

How to prevent TextBox to move scrollbar and text when writing text to it?

Whenever I write line to TextBox that is wider than width of textbox the scrollbar moves with appended text. The problem is I want to have scrollbar maximally moved to the left (at the beginning of the line). Can be moved at the end of writing or just fixed and then moved manually by scrollbar.
My question can be duplicate, because I don't even know how to name this issue.
Maybe screenshots can easier introduce my problem. On the left there is a position of a text in TextBox automatically moved and on the right side is position of thet text in TextBox manually moved by me with scrollbar.
I use FastColoredTextBox in my project and I just found method my_text_box.ScrollLeft(); and works fine. Whenever text appends on textbox it moves to the left, no flickering etc.

Print entire panel without scroll bar

I want to print whole area even though the panel has scroll bar.
Preview shows like below
but I want to print whole area like
I tried client.height but get only screen shot.

Get location of the text box cursor

Note: I am talking about the text box cursor (aka the vertical line that shows where you're typing. Not the mouse)
As the nice note says above, I'm trying to get the location of the text cursor as a Point so I can show a popup below it. How do I do this?
Text box has a GetRectFromCharacterIndex method that you can use. For example:
textbox.GetRectFromCharacterIndex(textbox.CaretIndex)

Get text box's scrollbar position

I have a text box whose content is constantly changing and whenever that happens, the scrollbar automatically resets back to the top (not just the text box, another list view of mine behaves in the same manner). Is there anyway to save the current scroll position and then load it later? It's annoying to have to scroll the textbox/listview all the way down everytime the change occurs.
This behavior only occurs when you are using a normal TextBox with "multiline" set to true. If you use a RichTextBox instead, the scroll bar position will not change when new text is added.

need to find current textbox line in relationship to screen position

I have created a texteditor along with a function window.
the functionwindow is a listbox that is populated with all of the functions located in the textbox.
when the user double clicks on an item in the listbox, the textbox will find the function that was clicked on. its just using a simple search to find the text. the issue is that if the text is at the bottom of the window, then you still need to scroll to display it properly. is there a way to ... If line 200 of a textbox was located at the bottom of the screen to make it show at the top??? does this make any sense to anybody
Is it the ScrollToCaret function you want?

Categories