Reputation: 195
I want to add a scrollbar which can be used for both these richtextboxes in winforms so that when i scroll down, the text in these boxes goes down. Right now, both have different scrollbars. I have tried the following methods which didn't work:
Upvotes: 0
Views: 1010
Reputation: 1432
You can do like @szataniel write. For this, and scroll bar control on your form, set richTextBoxes property ScrollBar=None or SrollBar=Horizontal.
And then add code like this:
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
richTextBox1.SelectionStart = e.NewValue;
richTextBox1.ScrollToCaret();
richTextBox2.SelectionStart = e.NewValue;
richTextBox2.ScrollToCaret();
}
Also there is another variant. You can create your own RichTextBox class extands RichTextBox with synhroniztion methods like in the post by link
Upvotes: 0
Reputation: 760
You can disable scrollbars on your RichTextBox controls and add some VScrollBar control on the right or left. Please reference to MSDN description of this control: VScrollBar on MSDN
Upvotes: 1