Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
An application which I'm currently coding compares two imported xml documents and shows the differences between them. I want to be able to scroll down with one scroll bar and have the second scroll automatically duplicate the movement made by the first scroll bar. I've looked on Google for some information about the controls for listview and there doesn't seem to be much function with the scrollbars.

I've managed to lock the listview depending on the current row which the using is looking at using the directional keys to navigate the listview, but would prefer to use the scrollbars. I've included the code for locking the listview using the directional buttons to navigate;

C#
private void lvLive_SelectedIndexChanged(object sender, EventArgs e)
{
    if (lvLive.SelectedItems.Count > 0)
    {
        ListViewItem lvi = lvTest.Items[lvLive.SelectedItems[0].Index];
        lvi.Selected = true;
        lvi.EnsureVisible();
    }
}


C#
private void lvTest_SelectedIndexChanged(object sender, EventArgs e)
{
    if (lvTest.SelectedItems.Count > 0)
    {
        ListViewItem lvi = lvLive.Items[lvTest.SelectedItems[0].Index];
        lvi.Selected = true;
        lvi.EnsureVisible();
    }
}


Please someone help, it would put the finishing touch to my app!

Thanks

Danny
Posted
Updated 9-Dec-10 5:25am
v4

1 solution

The obvious way would be to disable the scroll bar for the listviews and add a separate vertical scrollbar control.

You will have to prepare the separate scroll bar yourself, handle its messages and then apply the settings to both listviews.
 
Share this answer
 
Comments
[no name] 9-Dec-10 7:54am    
Hmm, I suppose somebody had a better answer but did not wish to share it with us.
Danny Hulmston 9-Dec-10 10:12am    
Indeed they did

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900