Get text box's scrollbar position - c#

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.

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.

Is it possible to dynamically change tooltip text in C# without changing the behavior of the tooltip?

I have a ToolTip control I am using to display text from a control when the control's size is too small to display all the text. In general, this works fine, but the control's text updates frequently based on external events making the tooltip's text stale. If possible, I would like to be able to update the tooltip's text to match the control's text without changing the tooltip's behavior. By this, I mean change the tooltip's text without changing the timing of when the tooltip is displayed and hidden.
I have tried using SetToolTip, but this causes the tooltip to appear immediately if the control's text changes while the mouse is hovering over the control rather than waiting the 500ms delay setting. Also, updating the text in this manner keeps the tooltip from ever timing out.

How can I make the text in a Picker's selection dialog wrap when too long?

I'm working with Xamarin.Forms, and the problem that I'm running into is wrapping text in the selection dialog.
I know I can change the appearance of the Picker itself using a custom renderer (which I have already done), but I can't figure out how to change the appearance/behavior of the selection dialog. Here's an example screenshot:
As you can see, the text on this last option is too long and stretches beyond the boundaries of the selection dialog. How can I get this text to wrap?

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

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?

Prevent RichTextBox from auto scrolling

I want to append text to a RichTextBox control but I don't want to interfere with the user's scroll position or text selection. The best that I've been able to do so far is to save the SelectionStart and SelectionLength properties and restore them after I append my text. This is close but the cursor ends up at the top of the control rather than wherever it was prior to the append. Is this possible?
Ok here is exactly what you need: Richtextbox :- controlling scrolling when appending text.
There you will find how to lock the scroll when appending text.
Look for CoolColin answer:
The trick is to use the Windows EM_HIDESELECTION call (this is different to the # hideselection), and also to temporarily remove the focus.
You can use the SelectionStart property of your RichTextBox control to "Gets or sets the starting point of text selected in the text box." with the values you already stored.
Have a look at RichTextBox Class. At the end you need to use TextBoxBase.ScrollToCaret method.

Categories