VB 6.0 - example of two grids(sheridan grids) scrolling in sync using a single scroll bar

Asked By harini on 09-Feb-10 11:44 PM
example of two grids(sheridan grids) scrolling in sync using a single scroll bar
Web Star replied to harini on 09-Feb-10 11:59 PM
the grid functions as though the Scrollable property is set to True: If more data exists than can be displayed, a scroll bar appears automatically.
Santhosh N replied to harini on 10-Feb-10 12:10 AM
You could actually have a scroll to div as
<div id='div1' style="width:'100%'; height:'50%'; overflow:scroll;">
<datagrid>
</datagrid>
</div>

let me know what exactly your requirement is if this is not what you anticipate
harini replied to Santhosh N on 10-Feb-10 02:22 AM
There are two sheridan grids of same size.
First grid has horizontal scrollbar to scroll the columns.
Second grid has no scroll bar.
Now thw problem is that when i scroll the scroll bar of first grid ,i want the columns of the second grid also to scroll
simultaneously.
Can you please help me out how do both grids scroll simultaneously using single scroll bar.


Thanks in advance.
Sai replied to harini on 04-Mar-10 10:08 AM

Private Sub ssdbGrid1_ScrollAfter()

Dim i%, j%, k%, l%, m%, n%
   
    i = ssdbGrid1.SplitterPos

    If ssdbGrid1.Columns(0).Position > ssdbGrid2.Columns(0).Position Then
        j = ssdbGrid1.Columns(0).Position + i
        k = ssdbGrid2.Columns(0).Position + i
    Else
        j = ssdbGrid1.Columns(0).Position - i
        k = ssdbGrid2.Columns(0).Position - i
    End If
   
   
          
    If j > k Then
        ssdbGrid2.Scroll j - k, 0
    Else
        If j >= -2 And j < k Then
            ssdbGrid2.Scroll j - k, 0
        End If
    End If

End Sub

Private Sub ssdbGrid1_KeyUp(KeyCode As Integer, Shift As Integer)

    'Keep synchronized horitonal scrolling when using navigation keys.
    If KeyCode = vbKeyLeft Or KeyCode = vbKeyRight Or KeyCode = vbKeyTab Then
        Call ssdbGrid1_ScrollAfter
    End If

End Sub