i have 6 side to side rtb's, im trying to keep the same vertical position for each of them. only the left most rtb actually has a visible scroll bar, the others do not. the idea is that as soon as the scroll changes in any of the rtb's, to set the same position in the rest.
so far my solution works...sort'of'ish. the problem im having is that when the scroll position changes, my rtb's freak out a little (the vertical position bounces around like crazy for about 500ms) and then end up at the right position eventually. i need a solution for this because for some reason during this little freak out session, my .SelectionStart property is getting set to 0 and causing problems elsewhere in my code.
Private Sub rtbEditCol_VScroll(ByVal sender As Object, ByVal e As System.EventArgs)
If bEditColXVScroll_Busy = False Then
If CheckIfSameNoOfLinesExistInAllColumns() Then
bEditColXVScroll_Busy = True
Dim iDestVerPos As Integer = 0
rtbEditColVScroll = CType(sender, RichTextBox)
Dim iVerPos As Integer = GetScrollPos(rtbEditColVScroll.Handle, SB_VERT)
iVerPos <<= 16
Dim wParam As UInteger = CUInt(SB_THUMBPOSITION) Or CUInt(iVerPos)
For n As Int16 = INAME_COL1 To LAST_DATA_COL_INDEX
With CType(Me.TableLayoutPanel1.Controls.Item(ColRtbNamePrefix & n), RichTextBox)
iDestVerPos = GetScrollPos(.Handle, SB_VERT)
If iVerPos <> iDestVerPos And rtbEditColVScroll.Name <> .Name Then
If (SetScrollPos(.Handle, SB_VERT, iVerPos, True) <> -1) Then
SendMessage(.Handle, WM_VSCROLL, New IntPtr(wParam), New IntPtr(0))
Debug.Print("Can't set info (Err: " & GetLastWin32Error() & ")")
bEditColXVScroll_Busy = False
from what i can debug, my problems seem to be getting caused within the DoEvents() method, however hopefully someone more wiser can point me in the right direction.
any help would be appreciated.