richtextbox vertical scroll problem

kanak

Newcomer
Joined
Jan 9, 2005
Messages
16
i m facing a problem in a rictextbox control.... that is the vertical scroll bar
i m developing a chat window where the message recieved is shown in a richtextbox ... Now the problem which i am facing is that

when the message content is more than the size of the richtextbox... then the vertical scrollbar is displayed..

but the scroll bar is not getting attached to the bottom position ... whenever a new message comes the scroll bar moves up .. and the message is not visible ... i have to move the scroll bar down to the bottom position to c the message...

how to make the vertical scroll bar position to the bottom ... so that the latest message can be seen without scrolling to the bottom...

for example u can try this..

create a richtextbox , a textbox, button..

type something in the textbox and click the button

on button click

richtextbox.text=richtextbox.text + textbox1.text

view the result when the messages r more then the size of the richtextbox...

i hope u might get the problem i am facing
 
kanak:
Give this a try:

Code:
private void AddMessage(string message)
{
	// Make RichTextBox active
	this.rtbTest.Focus();

	// Append Message
	this.rtbTest.AppendText(message);

	// Put the cursor at the very end of the text
	this.rtbTest.Select((this.rtbTest.Text.Length), 0);

	// Scroll
	this.rtbTest.ScrollToCaret();
}
 
Back
Top