Is there any third party tool available which has two richtextboxes but only a shared scroll bar for both. I need to implement some text in two different languages but both the textboxes should scroll at the same time.
Asked
Active
Viewed 1,711 times
4
-
Won't this solve your problem? http://stackoverflow.com/questions/1827323/c-synchronize-scroll-position-of-two-richtextboxes – Siddharth Rout Apr 22 '12 at 09:25
-
i dont want to have synchonization between two textboxes rather I want to provide same scroll bar between them – Tanuj Wadhwa Apr 22 '12 at 09:30
1 Answers
4
public enum ScrollBarType : uint
{
SbHorz = 0,
SbVert = 1,
SbCtl = 2,
SbBoth = 3
}
public enum Message : uint
{
WM_VSCROLL = 0x0115
}
public enum ScrollBarCommands : uint
{
SB_THUMBPOSITION = 4
}
[DllImport("User32.dll")]
public extern static int GetScrollPos(IntPtr hWnd, int nBar);
[DllImport("User32.dll")]
public extern static int SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
// Set the dual scrolling on the richTextbox1 and affects richTextbox2
private void richTextBox1_VScroll(object sender, EventArgs e)
{
int nPos = GetScrollPos(richTextBox1.Handle, (int)ScrollBarType.SbVert);
nPos <<= 16;
uint wParam = (uint)ScrollBarCommands.SB_THUMBPOSITION | (uint)nPos;
SendMessage(richTextBox2.Handle, (int)Message.WM_VSCROLL, new IntPtr(wParam), new IntPtr(0));
}

Pomster
- 14,567
- 55
- 128
- 204