在C#中锁定2个ListView滚动条 [英] Locking 2 listview scrollbars in c#

查看:158
本文介绍了在C#中锁定2个ListView滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在编码的应用程序比较两个导入的xml文档并显示它们之间的差异.我希望能够使用一个滚动条向下滚动,并让第二个滚动条自动复制第一个滚动条进行的移动.我在Google上查找了有关listview控件的一些信息,并且滚动条似乎没有太多功能.

我设法使用方向键来导航列表视图,从而根据使用者正在查看的当前行锁定列表视图,但希望使用滚动条.我已经包含了使用方向按钮进行导航锁定列表视图的代码;

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;

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();
    }
}





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();
    }
}



请有人帮忙,它将为我的应用程序画龙点睛!

谢谢

Danny



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

Thanks

Danny

推荐答案

最明显的方法是禁用列表视图的滚动条,并添加一个单独的垂直滚动条控件.
您必须自己准备单独的滚动条,处理其消息,然后将设置应用于两个列表视图.
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.


这篇关于在C#中锁定2个ListView滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆