Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

kanak:

Give this a try:

 


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();
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...