473,396 Members | 2,052 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,396 software developers and data experts.

Hold Scroll Bar on the bottom

Hi!
Im writing a simple chat, using ReachTextBox as chat viewer, but when the
RTB begins to scroll, the scrollbar not scroll down.
How can i do scroll down automatically?

Thanks!
Jun 1 '06 #1
2 4075
Kevin,

If you are ok with changing the position of the caret, then you can set
the SelectionStart property to the length of the text in the control, then,
you would call the ScrollToCaret method on the RichTextBox to scroll to the
end.

If you do not want to change the location of the caret, then you can use
this code:

private const int WM_VSCROLL = 0x115;
private const int SB_BOTTOM = 7;

[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam,
IntPtr lParam);

// Scroll to the bottom, but don't move the caret position.
SendMessage(textBox1.Handle, WM_VSCROLL, (IntPtr) SB_BOTTOM, IntPtr.Zero);

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kevin" <@> wrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi!
Im writing a simple chat, using ReachTextBox as chat viewer, but when the
RTB begins to scroll, the scrollbar not scroll down.
How can i do scroll down automatically?

Thanks!

Jun 1 '06 #2
Nicholas Paldino [.NET/C# MVP] wrote:
Kevin,

If you are ok with changing the position of the caret, then you can set
the SelectionStart property to the length of the text in the control, then,
you would call the ScrollToCaret method on the RichTextBox to scroll to the
end.

If you do not want to change the location of the caret, then you can use
this code:

private const int WM_VSCROLL = 0x115;
private const int SB_BOTTOM = 7;

[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam,
IntPtr lParam);

// Scroll to the bottom, but don't move the caret position.
SendMessage(textBox1.Handle, WM_VSCROLL, (IntPtr) SB_BOTTOM, IntPtr.Zero);

Hope this helps.


Wouldn't it be better to use PostMessage() in case the code is every
called from a different thread?

Jim
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
You roll an 18 in Dex and see if you
don't end up with a girlfriend
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
JimD
Central FL, USA, Earth, Sol
Jun 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: AES/newspost | last post by:
Just been involved with a web site where clicking a button on the main page opened a second (or secondary) window intended to function like a dialog box in Apple GUI jargon. (The primary page was...
4
by: Mad Scientist Jr | last post by:
I have a textbox that i am adding to (in codebehind of ASP.NET) and need to ensure that the focus is scrolled to the bottom of the textbox each time the page refreshes, and then set focus to a 2nd...
14
by: Simon Wigzell | last post by:
I want to display HTML text inside a div and have the page open scrolled to the bottom. (My div has overflow:auto so that it appears with scroll bars) I have found this that works on a textarea:...
1
by: web1110 | last post by:
Hi y'all, I've put together a ComboBox to display in a DataGrid - just to do it. It works fine, except... I added more entries to my test data, enough to scroll and: I select a row in the...
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...
4
by: John Dann | last post by:
I have a listview control on a simple vb.net form that's populated programmatically. It is set to scrollable and a scroll bar duly appears. However the scroll bar doesn't allow the bottom rows of...
0
by: jasondavidcarr | last post by:
Hello all, I have a "comments" page that contains three sections; the article to be commented on is on top, followed by previous comments, and on the bottom a place to add new comments. It's a...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using the VScrollBar and set it as follow: m_vScrollBar.Minimum = -19602; m_vScrollBar.Maximum = 0; m_vScrollBar.SmallChange = 1; m_vScrollBar.LargeChange = 1089; m_vScrollBar.Value =...
3
by: bgold12 | last post by:
How can I test if a vertical scroll bar is at the bottom of the range? I know that... document.getElementById('mydiv').scrollHeight ....returns the range, and... ...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
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.