Trying to force a vertical scrollbar to the "Bottom".

B

buht

Hello Everyone,

Fairly new to c# here and have a question regarding scrollbars,
particularly a vertical scrollbar.

It looks like my options are restricted for the textbox scrollbars
being that I can enable vertical or horizontal scrollbars for the
textbox and their wrapping but thats it for modifications of the
scrollbar.

I'm trying to figure out a way to force a textbox vertical scrollbar
to the bottom, even after the textbox update with more data.

Right now i append data to a textbox and when the visible section of
the textbox goes beyond the screen area, each following textbox update
makes the scrollbar reset to the very top again. This only happens if
the user moved the scrollbar down before another update occurs.

I want to force that sucker to the bottom. Can i do something to force
its location perhaps in an event or somewhere?

-Buht
 
D

David McClarnon

buht said:
Hello Everyone,

Fairly new to c# here and have a question regarding scrollbars,
particularly a vertical scrollbar.

It looks like my options are restricted for the textbox scrollbars
being that I can enable vertical or horizontal scrollbars for the
textbox and their wrapping but thats it for modifications of the
scrollbar.

I'm trying to figure out a way to force a textbox vertical scrollbar
to the bottom, even after the textbox update with more data.

Right now i append data to a textbox and when the visible section of
the textbox goes beyond the screen area, each following textbox update
makes the scrollbar reset to the very top again. This only happens if
the user moved the scrollbar down before another update occurs.

I want to force that sucker to the bottom. Can i do something to force
its location perhaps in an event or somewhere?

-Buht

Change the selection to the end of the text (length of the text + 1) and
that should do it.

textBox.SelectionStart = textBox.Text.Length;
textBox.SelectionLength = 0;

Try that.

Darwen.
 
B

buht

David McClarnon said:
Change the selection to the end of the text (length of the text + 1) and
that should do it.

textBox.SelectionStart = textBox.Text.Length;
textBox.SelectionLength = 0;

Try that.

Darwen.


Doesnt seem to be working. I set both of those member values to what
you recommended in the constructor of the form and its textbox. Then i
created a separate function to call after each update of my textbox
data with thosee values to try to force the location again.

I also turned off hideselection to be sure. Hrm...
 
B

buht

Doesnt seem to be working. I set both of those member values to what
you recommended in the constructor of the form and its textbox. Then i
created a separate function to call after each update of my textbox
data with thosee values to try to force the location again.

I also turned off hideselection to be sure. Hrm...

I wanted to follow-up.. With the help of a fellow co-worker I
discovered that one thing was missing with the above to statements...
the textbox.scrolltocaret() function. Though my cursor was moving with
the above two statements, the scrollbar was not. Adding that
additional method to the two statements moves the attached bar to the
newly located cursor.

Thanks for your help!

Buht
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top